Skip to content

Instantly share code, notes, and snippets.

@mrrooijen
Created June 26, 2011 02:37
Show Gist options
  • Save mrrooijen/1047160 to your computer and use it in GitHub Desktop.
Save mrrooijen/1047160 to your computer and use it in GitHub Desktop.
Capistrano with Foreman Capfile
# encoding: utf-8
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
set :application, "hirefireapp"
set :repository, "[email protected]:meskyanichi/myapp.git"
set :branch, "develop"
set :rvm_ruby_string, "1.9.2"
set :deploy_to, "/var/applications/#{application}"
set :user, "deployer"
set :scm, :git
set :port, 1117
set :use_sudo, false
default_run_options[:pty] = true
role :web, "xxx.xx.xx.xx"
role :app, "xxx.xx.xx.xx"
role :db, "xxx.xx.xx.xx", :primary => true
after 'deploy:update', 'bundle:install'
after 'deploy:update', 'foreman:export'
after 'deploy:update', 'foreman:restart'
namespace :bundle do
desc "Installs the application dependencies"
task :install, :roles => :app do
run "cd #{current_path} && bundle --without development test"
end
end
namespace :foreman do
desc "Export the Procfile to Ubuntu's upstart scripts"
task :export, :roles => :app do
run "cd #{release_path} && rvmsudo bundle exec foreman export upstart /etc/init " +
"-f ./Procfile.production -a #{application} -u #{user} -l #{shared_path}/log"
end
desc "Start the application services"
task :start, :roles => :app do
sudo "start #{application}"
end
desc "Stop the application services"
task :stop, :roles => :app do
sudo "stop #{application}"
end
desc "Restart the application services"
task :restart, :roles => :app do
run "sudo start #{application} || sudo restart #{application}"
end
desc "Display logs for a certain process - arg example: PROCESS=web-1"
task :logs, :roles => :app do
run "cd #{current_path}/log && cat #{ENV["PROCESS"]}.log"
end
end
# stub out deploy:restart
namespace :deploy do
task :restart do
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment