Created
January 26, 2012 23:29
-
-
Save betamatt/1685835 to your computer and use it in GitHub Desktop.
Running delayed_job with foreman
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You're on your own for environment setup. Personally, I deploy out a .env file to the shared dir | |
# and symlink it the same way as what's done for the .foreman file here. | |
Capistrano::Configuration.instance(:must_exist).load do | |
_cset(:app_user, 'www-data') | |
_cset(:foreman_bin, 'bundle exec foreman') | |
namespace :foreman do | |
desc "Export the Procfile to Ubuntu's upstart scripts" | |
task :export, :roles => [:app, :queue] do | |
run "cd #{current_path} && #{foreman_bin} export upstart /etc/init -a #{application} -u #{app_user} -l #{latest_release}/log" | |
end | |
desc "Symlink foreman configuration" | |
task :symlink_config, :except => { :no_release => true } do | |
run <<-CMD | |
rm -f #{latest_release}/.foreman && | |
ln -s #{shared_path}/foreman #{latest_release}/.foreman | |
CMD | |
end | |
end | |
after 'deploy:finalize_update', 'foreman:symlink_config' | |
namespace :deploy do | |
desc "Start the application services" | |
task :start, :roles => [:app, :queue] do | |
sudo "start #{application}" | |
end | |
desc "Stop the application services" | |
task :stop, :roles => [:app, :queue] do | |
sudo "stop #{application}" | |
end | |
desc "Restart the application services" | |
task :restart, :roles => [:app, :queue] do | |
run "start #{application} || restart #{application}" | |
end | |
end | |
after "deploy:update", "foreman:export" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
queue: ./queue.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
exec bundle exec rake jobs:work RAILS_ENV=${RACK_ENV:-development} 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment