2012-06-07 16:13:58 +01:00
|
|
|
Capistrano::Configuration.instance(:must_exist).load do
|
|
|
|
|
|
|
|
namespace :resque do
|
|
|
|
task :start do
|
|
|
|
start_workers
|
|
|
|
end
|
|
|
|
|
|
|
|
task :stop do
|
|
|
|
stop_workers
|
|
|
|
end
|
|
|
|
|
|
|
|
task :restart do
|
|
|
|
stop_workers
|
|
|
|
start_workers
|
|
|
|
end
|
|
|
|
|
|
|
|
def rails_env
|
|
|
|
fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
|
|
|
|
end
|
|
|
|
|
|
|
|
def stop_workers
|
2012-06-29 14:09:06 +01:00
|
|
|
# ps = 'ps aux | grep resque | grep -v grep'
|
|
|
|
# run "#{ps} && kill -QUIT `#{ps} | awk '{ print $2 }'` || echo 'Workers already stopped!'"
|
|
|
|
run "cd #{fetch :current_path} && #{rails_env} bundle exec rake resque:stop_workers"
|
2012-06-07 16:13:58 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def start_workers
|
2012-12-13 17:38:04 +00:00
|
|
|
queue = [
|
2013-01-28 21:59:56 +00:00
|
|
|
:publish_observer,
|
|
|
|
:rpm_worker_observer,
|
|
|
|
:iso_worker_observer,
|
2012-12-13 17:38:04 +00:00
|
|
|
:fork_import,
|
|
|
|
:hook,
|
|
|
|
:clone_build,
|
2013-01-28 21:59:56 +00:00
|
|
|
:notification
|
2012-12-13 17:38:04 +00:00
|
|
|
].join(',')
|
|
|
|
run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=#{queue} #{rails_env} BACKGROUND=yes bundle exec rake resque:workers"
|
2012-06-07 16:13:58 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|