2012-04-04 17:50:05 +01:00
|
|
|
# -*- encoding : utf-8 -*-
|
|
|
|
Capistrano::Configuration.instance(:must_exist).load do
|
|
|
|
namespace :delayed_job do
|
|
|
|
def dj_queues
|
|
|
|
%w(fork import hook default)
|
|
|
|
end
|
|
|
|
|
|
|
|
def rails_env
|
|
|
|
fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
|
|
|
|
end
|
|
|
|
|
|
|
|
def roles
|
|
|
|
fetch(:delayed_job_server_role, :app)
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Stop the delayed_job process"
|
|
|
|
task :stop, :roles => lambda { roles } do
|
|
|
|
dj_queues.each do |queue|
|
2012-04-05 20:26:18 +01:00
|
|
|
run "cd #{current_path};#{rails_env} script/delayed_job --pid-dir=#{shared_path}/pids/#{queue} stop"
|
2012-04-04 17:50:05 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Start the delayed_job process"
|
|
|
|
task :start, :roles => lambda { roles } do
|
|
|
|
dj_queues.each do |queue|
|
2012-04-05 20:26:18 +01:00
|
|
|
run "cd #{current_path};#{rails_env} script/delayed_job --queue=#{queue} -p #{queue} --pid-dir=#{shared_path}/pids/#{queue} start"
|
2012-04-04 17:50:05 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Restart the delayed_job process"
|
|
|
|
task :restart, :roles => lambda { roles } do
|
2012-04-05 19:06:24 +01:00
|
|
|
dj_queues.each do |queue|
|
2012-04-05 20:26:18 +01:00
|
|
|
run "cd #{current_path};#{rails_env} script/delayed_job --queue=#{queue} -p #{queue} --pid-dir=#{shared_path}/pids/#{queue} restart"
|
2012-04-05 19:06:24 +01:00
|
|
|
end
|
2012-04-04 17:50:05 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|