Created
February 2, 2016 01:11
-
-
Save tadyjp/7fd9f2b0b5d4297d2525 to your computer and use it in GitHub Desktop.
Revisions
-
tadyjp created this gist
Feb 2, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ 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