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.
This commit is contained in:
Javi Martín
2019-10-09 14:37:35 +02:00
parent dd8bc5cea7
commit 94a7e13dce

View File

@@ -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