Commit e1c18e60319468fdb5c2ee7477198e658b6b84b4

Authored by Andrei Gliga
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
Capfile
... ... @@ -4,5 +4,6 @@ require 'capistrano/deploy'
4 4 require 'capistrano/rbenv' if ENV['rbenv']
5 5 require 'capistrano/bundler'
6 6 require 'capistrano/rails/assets'
  7 +require 'capistrano/puma'
7 8  
8 9 Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
... ...
Gemfile
... ... @@ -76,6 +76,7 @@ group :development do
76 76 gem 'capistrano-bundler', require: false
77 77 gem 'capistrano-rails', require: false
78 78 gem 'capistrano-rbenv', require: false
  79 + gem 'capistrano3-puma', require: false
79 80  
80 81 # better errors
81 82 gem 'better_errors'
... ...
Gemfile.lock
... ... @@ -76,6 +76,9 @@ GEM
76 76 capistrano-rbenv (2.0.3)
77 77 capistrano (~> 3.1)
78 78 sshkit (~> 1.3)
  79 + capistrano3-puma (1.2.1)
  80 + capistrano (~> 3.0)
  81 + puma (>= 2.6)
79 82 capybara (2.4.4)
80 83 mime-types (>= 1.16)
81 84 nokogiri (>= 1.3.3)
... ... @@ -425,6 +428,7 @@ DEPENDENCIES
425 428 capistrano-bundler
426 429 capistrano-rails
427 430 capistrano-rbenv
  431 + capistrano3-puma
428 432 capybara
429 433 coveralls
430 434 decent_exposure
... ...
config/deploy.example.rb
... ... @@ -21,7 +21,7 @@ set :ssh_options, forward_agent: true
21 21 set :linked_files, fetch(:linked_files, []) + %w(
22 22 .env
23 23 config/newrelic.yml
24   - config/unicorn.rb
  24 + config/puma.rb
25 25 )
26 26  
27 27 set :linked_dirs, fetch(:linked_dirs, []) + %w(
... ... @@ -46,7 +46,7 @@ namespace :errbit do
46 46  
47 47 {
48 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 50 }.each do |src, target|
51 51 unless test("[ -f #{shared_path}/#{target} ]")
52 52 upload! src, "#{shared_path}/#{target}"
... ... @@ -69,47 +69,5 @@ namespace :db do
69 69 end
70 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"
... ...