Last active
December 30, 2015 20:09
-
-
Save coffeeaddict/7879143 to your computer and use it in GitHub Desktop.
unicorns.cap
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 :unicorns do | |
def unicorn_command | |
fetch(:unicorn_command, File.join(shared_path, "bin/unicorn_rails")) | |
end | |
def unicorn_pid_file | |
fetch(:unicorn_pid_file, "/path/to/unicorn.pid") | |
end | |
def unicorn_config_file | |
fetch(:unicorn_config_file, "config/unicorn.rb") | |
end | |
desc "Stop the unicorns" | |
task :stop do | |
on roles(:app) do | |
begin | |
execute "kill -QUIT `cat #{unicorn_pid_file}`" | |
rescue | |
# not running | |
end | |
end | |
end | |
desc "Start the unicorns" | |
task :start do | |
on roles(:app) do | |
within release_path do | |
execute unicorn_command, '-c', unicorn_config_file, '-D' | |
end | |
end | |
end | |
desc "Replace the unicorns (0-down-time deploy)" | |
task :replace do | |
on roles(:app) do | |
begin | |
execute "kill -USR2 `cat #{unicorn_pid_file}`" | |
rescue | |
# not running | |
end | |
end | |
end | |
desc "Hard restart the herd" | |
task :restart => [ :stop, :start ] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment