From e9520ab02cbb029fe3a057e3db85afdc892a574a Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 10 Feb 2014 23:59:03 +0400 Subject: [PATCH] Hotfix --- lib/recipes/resque.rb | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/recipes/resque.rb b/lib/recipes/resque.rb index 97f03ca7d..afae87b5a 100644 --- a/lib/recipes/resque.rb +++ b/lib/recipes/resque.rb @@ -3,18 +3,15 @@ Capistrano::Configuration.instance(:must_exist).load do namespace :resque do task :start do start_workers - invoke "resque:scheduler:start" end task :stop do stop_workers - invoke "resque:scheduler:stop" end task :restart do stop_workers start_workers - invoke "resque:scheduler:restart" end def rails_env @@ -56,22 +53,31 @@ Capistrano::Configuration.instance(:must_exist).load do desc "Starts resque scheduler with default configs" task :start do - pid = "#{fetch :current_path}/tmp/pids/scheduler.pid" - run "cd #{fetch :current_path} && #{rails_env} PIDFILE=#{pid} BACKGROUND=yes VERBOSE=1 MUTE=1 bundle exec rake resque:scheduler" + start_scheduler end desc "Stops resque scheduler" task :stop do + stop_scheduler + end + + task :restart do + stop_scheduler + start_scheduler + end + + def start_scheduler + pid = "#{fetch :current_path}/tmp/pids/scheduler.pid" + run "cd #{fetch :current_path} && #{rails_env} PIDFILE=#{pid} BACKGROUND=yes VERBOSE=1 MUTE=1 bundle exec rake resque:scheduler" + end + + def stop_scheduler pid = "#{fetch :current_path}/tmp/pids/scheduler.pid" if remote_file_exists?(pid) run "cd #{fetch :current_path} && kill -s QUIT $(cat #{pid}); rm #{pid}" end end - task :restart do - invoke "resque:scheduler:stop" - invoke "resque:scheduler:start" - end end end