Files
danbooru/lib/capistrano/tasks/unicorn.rake
evazion 5acc75d21b capistrano: fix sleep calls.
Minor optimization for `cap production deploy --dry-run`. Sleep on the
server instead of in the client.
2019-08-12 18:22:44 -05:00

26 lines
643 B
Ruby

# 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