public
Last active

Running delayed_job with foreman

  • Download Gist
Procfile
1
queue: ./queue.sh
capistrano_hooks.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
# 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
queue.sh
Shell
1 2
#!/bin/sh
exec bundle exec rake jobs:work RAILS_ENV=${RACK_ENV:-development} 2>&1

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.