Permalink
Browse files

Make delayed job tasks more flexible

  • Loading branch information...
1 parent 1163813 commit f32818ef99373a4eb6112bad0d27a64d2ca9a408 @ffmike committed Nov 30, 2011
Showing with 23 additions and 7 deletions.
  1. +2 −0 recipes/defaults.rb
  2. +21 −7 recipes/delayed_job.rb
View
@@ -39,6 +39,8 @@
# sync_assets_via: :scp, :rsync, :none
set :sync_assets_via, :scp
set :enable_delayed_job, false
+# script, monit
+set :delayed_job_manager, :script
set :database_type, "postgresql"
# SSH options
View
@@ -1,18 +1,33 @@
namespace :daemons do
namespace :delayed_job do
- desc "Start delayed_job process"
+ desc "Start delayed_job process"
task :start, :roles => :app do
- run "cd #{current_path}; script/delayed_job start -- #{rails_env}"
+ case fetch(:delayed_job_manager, :script)
+ when :script
+ run "cd #{current_path}; script/delayed_job start -- #{rails_env}"
+ when :monit
+ sudo "monit -g delayed_jobs start all"
+ end
end
- desc "Stop delayed_job process"
+ desc "Stop delayed_job process"
task :stop, :roles => :app do
- run "cd #{current_path}; script/delayed_job stop -- #{rails_env}"
+ case fetch(:delayed_job_manager, :script)
+ when :script
+ run "cd #{current_path}; script/delayed_job stop -- #{rails_env}"
+ when :monit
+ sudo "monit -g delayed_jobs stop all"
+ end
end
- desc "Restart delayed_job process"
+ desc "Restart delayed_job process"
task :restart, :roles => :app do
- run "cd #{current_path}; script/delayed_job restart -- #{rails_env}"
+ case fetch(:delayed_job_manager, :script)
+ when :script
+ run "cd #{current_path}; script/delayed_job restart -- #{rails_env}"
+ when :monit
+ sudo "monit -g delayed_jobs restart all"
+ end
end
end
end
@@ -23,4 +38,3 @@
after "deploy:restart", "daemons:delayed_job:start"
end
end
-

0 comments on commit f32818e

Please sign in to comment.