Skip to content

Instantly share code, notes, and snippets.

@coffeeaddict
Last active December 30, 2015 20:09
Show Gist options
  • Save coffeeaddict/7879143 to your computer and use it in GitHub Desktop.
Save coffeeaddict/7879143 to your computer and use it in GitHub Desktop.
unicorns.cap
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