Skip to content

Instantly share code, notes, and snippets.

@pragmaticivan
Created July 29, 2014 19:51
Show Gist options
  • Save pragmaticivan/e014a5a00345d38b974e to your computer and use it in GitHub Desktop.
Save pragmaticivan/e014a5a00345d38b974e to your computer and use it in GitHub Desktop.
#...
set :app_path, "#{deploy_to}/#{current_path}"
#...
desc "Deploys the current version to the server."
task :deploy => :environment do
deploy do
#...
to :launch do
invoke :'unicorn:restart'
#...
end
end
end
namespace :unicorn do
set :unicorn_pid, "#{deploy_to}/shared/pids/unicorn.pid"
set :start_unicorn, %{
cd #{app_path}
bundle exec unicorn -c #{app_path}/config/unicorn.rb -E #{rails_env} -D
}
# Start task
# ------------------------------------------------------------------------------
desc "Start unicorn"
task :start => :environment do
queue 'echo "-----> Start Unicorn"'
queue! start_unicorn
end
# Stop task
# ------------------------------------------------------------------------------
desc "Stop unicorn"
task :stop do
queue 'echo "-----> Stop Unicorn"'
queue! %{
test -s "#{unicorn_pid}" && kill -QUIT `cat "#{unicorn_pid}"` && echo "Stop Ok" && exit 0
echo >&2 "Not running"
}
end
# Restart task
# ------------------------------------------------------------------------------
desc "Restart unicorn using 'upgrade'"
task :restart => :environment do
invoke 'unicorn:stop'
invoke 'unicorn:start'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment