From e1c18e60319468fdb5c2ee7477198e658b6b84b4 Mon Sep 17 00:00:00 2001 From: Andrei Gliga Date: Mon, 14 Dec 2015 11:59:48 +0200 Subject: [PATCH] capistrano deploy with puma instead of unicorn Deploy example has been updated to use the capistrano3-puma gem for deploying --- Capfile | 1 + Gemfile | 1 + Gemfile.lock | 4 ++++ config/deploy.example.rb | 50 ++++---------------------------------------------- 4 files changed, 10 insertions(+), 46 deletions(-) diff --git a/Capfile b/Capfile index c963c3a..d5d842b 100644 --- a/Capfile +++ b/Capfile @@ -4,5 +4,6 @@ require 'capistrano/deploy' require 'capistrano/rbenv' if ENV['rbenv'] require 'capistrano/bundler' require 'capistrano/rails/assets' +require 'capistrano/puma' Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } diff --git a/Gemfile b/Gemfile index 0da950b..0ec2aa4 100644 --- a/Gemfile +++ b/Gemfile @@ -76,6 +76,7 @@ group :development do gem 'capistrano-bundler', require: false gem 'capistrano-rails', require: false gem 'capistrano-rbenv', require: false + gem 'capistrano3-puma', require: false # better errors gem 'better_errors' diff --git a/Gemfile.lock b/Gemfile.lock index 1b375e6..aff952a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -76,6 +76,9 @@ GEM capistrano-rbenv (2.0.3) capistrano (~> 3.1) sshkit (~> 1.3) + capistrano3-puma (1.2.1) + capistrano (~> 3.0) + puma (>= 2.6) capybara (2.4.4) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -425,6 +428,7 @@ DEPENDENCIES capistrano-bundler capistrano-rails capistrano-rbenv + capistrano3-puma capybara coveralls decent_exposure diff --git a/config/deploy.example.rb b/config/deploy.example.rb index 2675a59..5e3b6ef 100644 --- a/config/deploy.example.rb +++ b/config/deploy.example.rb @@ -21,7 +21,7 @@ set :ssh_options, forward_agent: true set :linked_files, fetch(:linked_files, []) + %w( .env config/newrelic.yml - config/unicorn.rb + config/puma.rb ) set :linked_dirs, fetch(:linked_dirs, []) + %w( @@ -46,7 +46,7 @@ namespace :errbit do { 'config/newrelic.example.yml' => 'config/newrelic.yml', - 'config/unicorn.default.rb' => 'config/unicorn.rb' + 'config/puma.default.rb' => 'config/puma.rb' }.each do |src, target| unless test("[ -f #{shared_path}/#{target} ]") upload! src, "#{shared_path}/#{target}" @@ -69,47 +69,5 @@ namespace :db do end end -set :unicorn_pidfile, "#{fetch(:deploy_to)}/shared/tmp/pids/unicorn.pid" -set :unicorn_pid, "`cat #{fetch(:unicorn_pidfile)}`" - -namespace :unicorn do - desc 'Start unicorn' - task :start do - on roles(:app) do - within current_path do - if test " [ -s #{fetch(:unicorn_pidfile)} ] " - warn "Unicorn is already running." - else - with "UNICORN_PID" => fetch(:unicorn_pidfile) do - execute :bundle, :exec, :unicorn, "-D -c ./config/unicorn.rb" - end - end - end - end - end - - desc 'Reload unicorn' - task :reload do - on roles(:app) do - execute :kill, "-HUP", fetch(:unicorn_pid) - end - end - - desc 'Stop unicorn' - task :stop do - on roles(:app) do - if test " [ -s #{fetch(:unicorn_pidfile)} ] " - execute :kill, "-QUIT", fetch(:unicorn_pid) - else - warn "Unicorn is not running." - end - end - end - - desc 'Reexecute unicorn' - task :reexec do - on roles(:app) do - execute :kill, "-USR2", fetch(:unicorn_pid) - end - end -end +set :puma_pid, "#{fetch(:deploy_to)}/shared/tmp/pids/puma.pid" +set :puma_conf, "#{shared_path}/config/puma.rb" -- libgit2 0.21.2