Skip to content

Instantly share code, notes, and snippets.

@cbilgili
Created March 19, 2015 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbilgili/7989ea3d047bf2e1a6b0 to your computer and use it in GitHub Desktop.
Save cbilgili/7989ea3d047bf2e1a6b0 to your computer and use it in GitHub Desktop.
Foreman unicorn upstart rbenv
set :unicorn_port, 5087
namespace :foreman do
desc "Export the Procfile to Ubuntu's upstart scripts"
task :export do
on roles(:app) do
within current_path do
execute :rbenv, :sudo, "foreman export upstart /etc/init --procfile=./Procfile -a #{fetch(:application)} -p #{fetch(:unicorn_port)} -u #{fetch(:user)} -l #{shared_path}/log"
end
end
end
desc "Start the application services"
task :start do
on roles(:app) do
as :root do
within current_path do
execute :rbenv, :sudo, "start #{fetch(:application)}"
end
end
end
end
desc "Stop the application services"
task :stop do
on roles(:app) do
as :root do
within current_path do
execute :rbenv, :sudo, "stop #{fetch(:application)}"
end
end
end
end
desc "Restart the application services"
task :restart do
on roles(:app) do
as :root do
within current_path do
execute :rbenv, :sudo, "start #{fetch(:application)} || restart #{fetch(:application)}"
end
end
end
end
end
after "deploy:publishing", "foreman:export"
after "deploy:publishing", "foreman:restart"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment