Commit e1c18e60319468fdb5c2ee7477198e658b6b84b4
1 parent
8ab783d0
Exists in
master
capistrano deploy with puma instead of unicorn
Deploy example has been updated to use the capistrano3-puma gem for deploying
Showing
4 changed files
with
10 additions
and
46 deletions
Show diff stats
Capfile
| @@ -4,5 +4,6 @@ require 'capistrano/deploy' | @@ -4,5 +4,6 @@ require 'capistrano/deploy' | ||
| 4 | require 'capistrano/rbenv' if ENV['rbenv'] | 4 | require 'capistrano/rbenv' if ENV['rbenv'] |
| 5 | require 'capistrano/bundler' | 5 | require 'capistrano/bundler' |
| 6 | require 'capistrano/rails/assets' | 6 | require 'capistrano/rails/assets' |
| 7 | +require 'capistrano/puma' | ||
| 7 | 8 | ||
| 8 | Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } | 9 | Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } |
Gemfile
| @@ -76,6 +76,7 @@ group :development do | @@ -76,6 +76,7 @@ group :development do | ||
| 76 | gem 'capistrano-bundler', require: false | 76 | gem 'capistrano-bundler', require: false |
| 77 | gem 'capistrano-rails', require: false | 77 | gem 'capistrano-rails', require: false |
| 78 | gem 'capistrano-rbenv', require: false | 78 | gem 'capistrano-rbenv', require: false |
| 79 | + gem 'capistrano3-puma', require: false | ||
| 79 | 80 | ||
| 80 | # better errors | 81 | # better errors |
| 81 | gem 'better_errors' | 82 | gem 'better_errors' |
Gemfile.lock
| @@ -76,6 +76,9 @@ GEM | @@ -76,6 +76,9 @@ GEM | ||
| 76 | capistrano-rbenv (2.0.3) | 76 | capistrano-rbenv (2.0.3) |
| 77 | capistrano (~> 3.1) | 77 | capistrano (~> 3.1) |
| 78 | sshkit (~> 1.3) | 78 | sshkit (~> 1.3) |
| 79 | + capistrano3-puma (1.2.1) | ||
| 80 | + capistrano (~> 3.0) | ||
| 81 | + puma (>= 2.6) | ||
| 79 | capybara (2.4.4) | 82 | capybara (2.4.4) |
| 80 | mime-types (>= 1.16) | 83 | mime-types (>= 1.16) |
| 81 | nokogiri (>= 1.3.3) | 84 | nokogiri (>= 1.3.3) |
| @@ -425,6 +428,7 @@ DEPENDENCIES | @@ -425,6 +428,7 @@ DEPENDENCIES | ||
| 425 | capistrano-bundler | 428 | capistrano-bundler |
| 426 | capistrano-rails | 429 | capistrano-rails |
| 427 | capistrano-rbenv | 430 | capistrano-rbenv |
| 431 | + capistrano3-puma | ||
| 428 | capybara | 432 | capybara |
| 429 | coveralls | 433 | coveralls |
| 430 | decent_exposure | 434 | decent_exposure |
config/deploy.example.rb
| @@ -21,7 +21,7 @@ set :ssh_options, forward_agent: true | @@ -21,7 +21,7 @@ set :ssh_options, forward_agent: true | ||
| 21 | set :linked_files, fetch(:linked_files, []) + %w( | 21 | set :linked_files, fetch(:linked_files, []) + %w( |
| 22 | .env | 22 | .env |
| 23 | config/newrelic.yml | 23 | config/newrelic.yml |
| 24 | - config/unicorn.rb | 24 | + config/puma.rb |
| 25 | ) | 25 | ) |
| 26 | 26 | ||
| 27 | set :linked_dirs, fetch(:linked_dirs, []) + %w( | 27 | set :linked_dirs, fetch(:linked_dirs, []) + %w( |
| @@ -46,7 +46,7 @@ namespace :errbit do | @@ -46,7 +46,7 @@ namespace :errbit do | ||
| 46 | 46 | ||
| 47 | { | 47 | { |
| 48 | 'config/newrelic.example.yml' => 'config/newrelic.yml', | 48 | 'config/newrelic.example.yml' => 'config/newrelic.yml', |
| 49 | - 'config/unicorn.default.rb' => 'config/unicorn.rb' | 49 | + 'config/puma.default.rb' => 'config/puma.rb' |
| 50 | }.each do |src, target| | 50 | }.each do |src, target| |
| 51 | unless test("[ -f #{shared_path}/#{target} ]") | 51 | unless test("[ -f #{shared_path}/#{target} ]") |
| 52 | upload! src, "#{shared_path}/#{target}" | 52 | upload! src, "#{shared_path}/#{target}" |
| @@ -69,47 +69,5 @@ namespace :db do | @@ -69,47 +69,5 @@ namespace :db do | ||
| 69 | end | 69 | end |
| 70 | end | 70 | end |
| 71 | 71 | ||
| 72 | -set :unicorn_pidfile, "#{fetch(:deploy_to)}/shared/tmp/pids/unicorn.pid" | ||
| 73 | -set :unicorn_pid, "`cat #{fetch(:unicorn_pidfile)}`" | ||
| 74 | - | ||
| 75 | -namespace :unicorn do | ||
| 76 | - desc 'Start unicorn' | ||
| 77 | - task :start do | ||
| 78 | - on roles(:app) do | ||
| 79 | - within current_path do | ||
| 80 | - if test " [ -s #{fetch(:unicorn_pidfile)} ] " | ||
| 81 | - warn "Unicorn is already running." | ||
| 82 | - else | ||
| 83 | - with "UNICORN_PID" => fetch(:unicorn_pidfile) do | ||
| 84 | - execute :bundle, :exec, :unicorn, "-D -c ./config/unicorn.rb" | ||
| 85 | - end | ||
| 86 | - end | ||
| 87 | - end | ||
| 88 | - end | ||
| 89 | - end | ||
| 90 | - | ||
| 91 | - desc 'Reload unicorn' | ||
| 92 | - task :reload do | ||
| 93 | - on roles(:app) do | ||
| 94 | - execute :kill, "-HUP", fetch(:unicorn_pid) | ||
| 95 | - end | ||
| 96 | - end | ||
| 97 | - | ||
| 98 | - desc 'Stop unicorn' | ||
| 99 | - task :stop do | ||
| 100 | - on roles(:app) do | ||
| 101 | - if test " [ -s #{fetch(:unicorn_pidfile)} ] " | ||
| 102 | - execute :kill, "-QUIT", fetch(:unicorn_pid) | ||
| 103 | - else | ||
| 104 | - warn "Unicorn is not running." | ||
| 105 | - end | ||
| 106 | - end | ||
| 107 | - end | ||
| 108 | - | ||
| 109 | - desc 'Reexecute unicorn' | ||
| 110 | - task :reexec do | ||
| 111 | - on roles(:app) do | ||
| 112 | - execute :kill, "-USR2", fetch(:unicorn_pid) | ||
| 113 | - end | ||
| 114 | - end | ||
| 115 | -end | 72 | +set :puma_pid, "#{fetch(:deploy_to)}/shared/tmp/pids/puma.pid" |
| 73 | +set :puma_conf, "#{shared_path}/config/puma.rb" |