From e3c6fc77c623494915fdeec83ad527dac1f2dec1 Mon Sep 17 00:00:00 2001 From: voodoorai2000 Date: Fri, 21 Sep 2018 15:39:56 +0200 Subject: [PATCH] Update Unicorn restart task We are using a simple unicorn.rb file in the Installer, which requires a different way of restarting the server This task is still a little limited and hackish but it does the job for now :relieved: We are killing any existing unicorn process and starting unicorn. It checks for existing processes in both the standard consul folder and in the capistrano `current` folder, and skipping any exception if unicorn was not running. --- lib/capistrano/tasks/restart.cap | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/capistrano/tasks/restart.cap b/lib/capistrano/tasks/restart.cap index 54c90819a..787191056 100644 --- a/lib/capistrano/tasks/restart.cap +++ b/lib/capistrano/tasks/restart.cap @@ -1,10 +1,8 @@ -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 - end +desc 'Restart Unicorn' +task :restart do + on roles(:app) do + execute "kill -QUIT `cat /home/deploy/consul/pids/unicorn.pid`; true" + execute "kill -QUIT `cat /home/deploy/consul/shared/pids/unicorn.pid`; true" + execute "cd /home/deploy/consul/current && /home/deploy/.rvm/gems/ruby-2.3.2/wrappers/unicorn -c config/unicorn.rb -E production -D" end -end +end \ No newline at end of file