From cd5224610b54100f139b934c4ef192827c224f64 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 9 Dec 2018 09:24:08 +0500 Subject: [PATCH] Add Capistrano task "puma:stop" --- config/deploy/production.rb | 4 ---- config/puma/development.rb | 5 +++++ config/puma/production.rb | 5 +++++ lib/capistrano/tasks/puma.rake | 13 +++++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 lib/capistrano/tasks/puma.rake diff --git a/config/deploy/production.rb b/config/deploy/production.rb index 168bfdc..de77ee2 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -7,10 +7,6 @@ namespace :deploy do desc 'Restart application services' task :restart do - on roles(:web) do - execute :sudo, :systemctl, :restart, 'partynest-web.service' - end - on roles(:app) do execute :sudo, :systemctl, :restart, 'partynest-worker.service' end diff --git a/config/puma/development.rb b/config/puma/development.rb index c79c187..755d3ee 100644 --- a/config/puma/development.rb +++ b/config/puma/development.rb @@ -33,3 +33,8 @@ port ENV.fetch('PORT') { 3000 } # Allow puma to be restarted by `rails restart` command. plugin :tmp_restart + +# Use "path" as the file to store the server info state. This is +# used by "pumactl" to query and control the server. +# +state_path Rails.root.join('tmp', 'pids', 'puma.state') diff --git a/config/puma/production.rb b/config/puma/production.rb index a72619a..0dbec46 100644 --- a/config/puma/production.rb +++ b/config/puma/production.rb @@ -33,3 +33,8 @@ bind "unix://#{Rails.root.join('tmp', 'sockets', 'puma.sock')}" # Allow puma to be restarted by `rails restart` command. # plugin :tmp_restart + +# Use "path" as the file to store the server info state. This is +# used by "pumactl" to query and control the server. +# +state_path Rails.root.join('tmp', 'pids', 'puma.state') diff --git a/lib/capistrano/tasks/puma.rake b/lib/capistrano/tasks/puma.rake new file mode 100644 index 0000000..2ecc52e --- /dev/null +++ b/lib/capistrano/tasks/puma.rake @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +namespace :puma do + desc 'Stop Puma web server' + task :stop do + on roles(:web) do + within release_path do + statefile = File.join shared_path, 'tmp', 'pids', 'puma.state' + execute :bundle, :exec, :pumactl, '--state', statefile, :stop + end + end + end +end