Skip to content

Instantly share code, notes, and snippets.

@koenpunt
Last active December 11, 2015 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save koenpunt/4630100 to your computer and use it in GitHub Desktop.
Save koenpunt/4630100 to your computer and use it in GitHub Desktop.
Capistrano recipe for foreman in production
set :user, "deploy"
set :runner, "deploy"
set :application, "example.com"
set :deploy_to, "/var/apps/#{application}"
set :shared_children, %w(sockets)
set :scm, :git
set :repository, "git@github.com:example.git"
set :deploy_via, :remote_cache
set :ssh_options, { :forward_agent => true }
server "example.com", :app, :web, :db, :primary => true
# if you want to clean up old releases on each deploy uncomment this:
after "deploy:restart", "deploy:cleanup"
after "deploy:restart", "foreman:restart"
after "deploy:update", "foreman:export"
after "deploy:update", "foreman:restart"
namespace :foreman do
desc "Export the Procfile to Ubuntu's upstart scripts"
task :export, :roles => :app do
invoke_command "sh -c 'cd #{release_path} && bundle exec foreman export upstart /etc/init -a #{application} -u #{user} -l #{shared_path}/log'", :via => run_method
end
desc "Start the application services"
task :start, :roles => :app do
invoke_command "service #{application} start", :via => run_method
end
desc "Stop the application services"
task :stop, :roles => :app do
invoke_command "service #{application} stop", :via => run_method
end
desc "Restart the application services"
task :restart, :roles => :app do
invoke_command "service #{application} restart", :via => run_method
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment