forked from e621ng/e621ng
force unicorn to terminate before restarting
This commit is contained in:
parent
f5a031c831
commit
d90fd6c46a
3
Capfile
3
Capfile
@ -13,4 +13,5 @@ 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:reload"
|
||||
after "deploy:published", "unicorn:terminate"
|
||||
after "deploy:published", "unicorn:start"
|
||||
|
16
lib/capistrano/tasks/unicorn.cap
Normal file
16
lib/capistrano/tasks/unicorn.cap
Normal file
@ -0,0 +1,16 @@
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user