capistrano: simplify unicorn:terminate task.
Use the builtin task provided by capistrano3-unicorn. Ours failed with invalid pidfile errors in some cases.
This commit is contained in:
@@ -9,7 +9,7 @@ namespace :app do
|
|||||||
# do nothing
|
# do nothing
|
||||||
else
|
else
|
||||||
invoke "web:disable"
|
invoke "web:disable"
|
||||||
invoke "unicorn:terminate"
|
invoke "unicorn:stop"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
# https://bogomips.org/unicorn/SIGNALS.html
|
|
||||||
namespace :unicorn do
|
|
||||||
desc "Terminate unicorn processes (blocks until complete)"
|
|
||||||
task :terminate do
|
|
||||||
on roles(:app) do
|
|
||||||
within current_path do
|
|
||||||
kill_unicorn("SIGQUIT")
|
|
||||||
execute :sleep, 10
|
|
||||||
kill_unicorn("SIGTERM")
|
|
||||||
execute :sleep, 2
|
|
||||||
kill_unicorn("SIGKILL")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def unicorn_running?
|
|
||||||
test("[ -f #{fetch(:unicorn_pid)} ] && pkill --count --pidfile #{fetch(:unicorn_pid)}")
|
|
||||||
end
|
|
||||||
|
|
||||||
def kill_unicorn(signal)
|
|
||||||
if unicorn_running?
|
|
||||||
execute :pkill, "--signal #{signal}", "--pidfile #{fetch(:unicorn_pid)}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user