summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLogan Fick <logaldeveloper@protonmail.com>2018-05-27 18:09:46 -0400
committerLogan Fick <logaldeveloper@protonmail.com>2018-05-27 18:09:46 -0400
commit3d8199c9f9186cec4b331edc50d99e5f1d5d11f2 (patch)
tree1d6d5f6283fd15a84c17e538bb105ad958a1bbcc
parent8f16fd709da25abda116e09015409d642932b85e (diff)
Reverted messy attempt at switch to Puma as app server.
-rw-r--r--Capfile11
-rw-r--r--Gemfile11
-rw-r--r--Gemfile.lock17
-rw-r--r--config/puma.rb23
-rw-r--r--lib/capistrano/tasks/unicorn.rake40
5 files changed, 57 insertions, 45 deletions
diff --git a/Capfile b/Capfile
index dd589a4..6ad9a5a 100644
--- a/Capfile
+++ b/Capfile
@@ -5,21 +5,16 @@ require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/bundler'
-require 'capistrano/puma'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
namespace :deploy do
desc 'Start application'
- task(:start) {
- invoke 'puma:start'
- }
+ task(:start) {}
desc 'Stop application'
- task(:stop) {
- invoke 'puma:stop'
- }
+ task(:stop) {}
end
# Load custom tasks from `lib/capistrano/tasks' if you have any defined
-Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
+Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } \ No newline at end of file
diff --git a/Gemfile b/Gemfile
index 690d7fb..09f297d 100644
--- a/Gemfile
+++ b/Gemfile
@@ -31,10 +31,9 @@ group :development do
gem 'binding_of_caller'
gem 'rails-erd'
# deploy with capistrano
- gem 'capistrano-rails'
- gem 'capistrano-rbenv'
- gem 'capistrano-bundler'
- gem 'capistrano-puma'
+ gem 'capistrano-rails', '~> 1.1.2'
+ gem 'capistrano-rbenv', '~> 2.0'
+ gem 'capistrano-bundler', '~> 1.1.3'
# windows timezone foo
gem 'tzinfo-data', platforms: [:mingw, :mswin]
end
@@ -44,6 +43,6 @@ group :test do
end
group :production do
- # Use puma as the app server
- gem 'puma'
+ # Use unicorn as the app server
+ gem 'unicorn'
end
diff --git a/Gemfile.lock b/Gemfile.lock
index e070a80..bd8feba 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -115,8 +115,6 @@ GEM
capistrano-bundler (1.1.4)
capistrano (~> 3.1)
sshkit (~> 1.2)
- capistrano-puma (0.2.3)
- capistrano (>= 3.0)
capistrano-rails (1.1.8)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
@@ -158,6 +156,7 @@ GEM
coffee-rails (>= 3.2.0)
railties (>= 3.2.0)
sass-rails (>= 3.2.0)
+ kgio (2.11.2)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
@@ -179,7 +178,6 @@ GEM
mini_portile2 (~> 2.3.0)
nokogumbo (1.5.0)
nokogiri
- puma (3.11.4)
rack (1.6.9)
rack-test (0.6.3)
rack (>= 1.0)
@@ -196,6 +194,7 @@ GEM
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
+ raindrops (0.19.0)
rake (12.3.0)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
@@ -245,6 +244,9 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
+ unicorn (5.4.0)
+ kgio (~> 2.6)
+ raindrops (~> 0.7)
webrick (1.4.2)
PLATFORMS
@@ -256,10 +258,9 @@ DEPENDENCIES
bcrypt
better_errors
binding_of_caller
- capistrano-bundler
- capistrano-puma
- capistrano-rails
- capistrano-rbenv
+ capistrano-bundler (~> 1.1.3)
+ capistrano-rails (~> 1.1.2)
+ capistrano-rbenv (~> 2.0)
highlight_js-rails!
hirb
jquery-rails
@@ -267,7 +268,6 @@ DEPENDENCIES
kaminari!
mail-gpg!
mysql2
- puma
rails!
rails-erd
rb-readline
@@ -279,6 +279,7 @@ DEPENDENCIES
strip_attributes
tzinfo-data
uglifier
+ unicorn
webrick
BUNDLED WITH
diff --git a/config/puma.rb b/config/puma.rb
deleted file mode 100644
index ce9e7e7..0000000
--- a/config/puma.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-workers 2
-
-threads 2, 4
-
-app_dir = File.expand_path("../..", __FILE__)
-shared_dir = "#{app_dir}/shared"
-
-rails_env = ENV['RAILS_ENV'] || "production"
-environment rails_env
-
-bind "localhost:8080"
-
-stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true
-
-pidfile "#{shared_dir}/pids/puma.pid"
-state_path "#{shared_dir}/pids/puma.state"
-activate_control_app
-
-on_worker_boot do
- require "active_record"
- ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
- ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/database.yml")[rails_env])
-end
diff --git a/lib/capistrano/tasks/unicorn.rake b/lib/capistrano/tasks/unicorn.rake
new file mode 100644
index 0000000..6d82d84
--- /dev/null
+++ b/lib/capistrano/tasks/unicorn.rake
@@ -0,0 +1,40 @@
+namespace :deploy do
+ after :start, :start_unicorn do
+ invoke 'unicorn:start'
+ end
+
+ after :stop, :stop_unicorn do
+ invoke 'unicorn:stop'
+ end
+
+ after :restart, :restart_unicorn do
+ begin
+ invoke "unicorn:restart"
+ rescue SSHKit::Runner::ExecuteError
+ invoke "unicorn:start"
+ end
+ end
+end
+
+namespace :unicorn do
+ desc "Start Unicorn"
+ task :start do
+ on roles(:web) do
+ execute :sudo, :start, "unicorn"
+ end
+ end
+
+ desc "Stop Unicorn"
+ task :stop do
+ on roles(:web) do
+ execute :sudo, :stop, "unicorn"
+ end
+ end
+
+ desc "Restart Unicorn"
+ task :restart do
+ on roles(:web), in: :sequence, wait: 5 do
+ execute :sudo, :restart, "unicorn"
+ end
+ end
+end \ No newline at end of file