From 94a7e13dce3ff56b03093f42972d88403f059f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 9 Oct 2019 14:37:35 +0200 Subject: [PATCH] Update capistrano's restart unicorn task Our current unicorn task wasn't working in some cases. We also had a version in the `capistrano` branch, which was the one we recommended. However, that version assumed RVM, a certain ruby version and a certain deploy folder were used. This version uses `bundle exec` and variables like `release_path`, so it does not depend on any specific configuration. Even if we're replacing unicorn with puma, I wanted to make this change in case we need it as a reference in the future. --- lib/capistrano/tasks/restart.cap | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/capistrano/tasks/restart.cap b/lib/capistrano/tasks/restart.cap index 54c90819a..e8975077e 100644 --- a/lib/capistrano/tasks/restart.cap +++ b/lib/capistrano/tasks/restart.cap @@ -1,10 +1,11 @@ namespace :deploy do - desc 'Commands for unicorn application' - %w(start stop force-stop restart upgrade reopen-logs).each do |command| - task command.to_sym do - on roles(:app), in: :sequence, wait: 5 do - execute "/etc/init.d/unicorn_#{fetch(:full_app_name)} #{command}" - end + desc "Restart Unicorn" + task :restart do + on roles(:app) do + execute "kill -QUIT `cat #{deploy_to}/pids/unicorn.pid`; true" + execute "kill -QUIT `cat #{shared_path}/pids/unicorn.pid`; true" + execute "kill -QUIT `cat #{shared_path}/tmp/pids/unicorn.pid`; true" + execute "cd #{release_path} && bundle exec unicorn -c config/unicorn.rb -E production -D" end end end