Created
February 2, 2016 01:11
-
-
Save tadyjp/7fd9f2b0b5d4297d2525 to your computer and use it in GitHub Desktop.
unicorn force restart sequentially (reload /etc/enviroment)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :unicorn do | |
desc 'Force restart Unicorn (sequential)' | |
task :force_restart do | |
on roles(fetch(:unicorn_roles)), in: :sequence, wait: 10 do | |
within current_path do | |
if test("[ -e #{fetch(:unicorn_pid)} ]") | |
if test("kill -0 #{pid}") | |
info 'stopping unicorn...' | |
execute :kill, '-s QUIT', pid | |
else | |
info 'cleaning up dead unicorn pid...' | |
execute :rm, fetch(:unicorn_pid) | |
end | |
sleep(3) | |
if test("[ -e #{fetch(:unicorn_pid)} ] && kill -0 #{pid}") | |
info 'unicorn is running...' | |
else | |
with rails_env: fetch(:rails_env) do | |
execute :bundle, 'exec unicorn', '-c', fetch(:unicorn_config_path), '-E', fetch(:unicorn_rack_env), '-D', fetch(:unicorn_options) | |
end | |
end | |
else | |
info 'unicorn is not running...' | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment