Reverted messy attempt at switch to Puma as app server.

This commit is contained in:
Logan Fick
2018-05-27 18:09:46 -04:00
parent 8f16fd709d
commit 3d8199c9f9
5 changed files with 57 additions and 45 deletions

11
Capfile
View File

@@ -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 }

11
Gemfile
View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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