terminate unicorn procs on deploy

This commit is contained in:
r888888888
2016-08-02 22:12:14 -07:00
parent d90fd6c46a
commit 7cf2dbc15b
2 changed files with 4 additions and 12 deletions

View File

@@ -12,6 +12,3 @@ require 'capistrano3/unicorn'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
after "deploy:published", "unicorn:terminate"
after "deploy:published", "unicorn:start"

View File

@@ -2,15 +2,10 @@ namespace :unicorn do
desc "Terminate unicorn processes (blocks until complete)"
task :terminate do
on roles(:app) do
n = 0
while n < 10 && !capture("pgrep -f unicorn").blank?
execute "pgrep -f unicorn | xargs -SIGTERM"
n += 1
end
if n == 10
execute "pgrep -f unicorn | xargs -SIGKILL"
end
execute "[[ -n $(pgrep -f unicorn) ]] && pgrep -f unicorn | xargs kill -SIGTERM"
end
end
end
after "deploy:published", "unicorn:terminate"
after "deploy:published", "unicorn:start"