From 3b415250eb4a9b117c2f26b8775bd6cca2b91835 Mon Sep 17 00:00:00 2001 From: Alexei Mikhailov Date: Tue, 18 Jun 2013 11:36:22 +0600 Subject: [PATCH] =?UTF-8?q?Fixed=20#33.=20rake=20resque:start=20=D1=82?= =?UTF-8?q?=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=B7=D0=B0=D0=BF=D1=83=D1=81?= =?UTF-8?q?=D0=BA=D0=B0=D0=B5=D1=82=20resque=20=D0=BF=D1=80=D0=B8=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D1=83=D1=89=D0=B5=D0=BD=D0=BD=D0=BE=D0=BC=20god?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/resque/integration/tasks/resque.rake | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/resque/integration/tasks/resque.rake b/lib/resque/integration/tasks/resque.rake index 74f6c09..9a50632 100644 --- a/lib/resque/integration/tasks/resque.rake +++ b/lib/resque/integration/tasks/resque.rake @@ -12,7 +12,9 @@ namespace :resque do desc 'Start God server and watch for Resque workers' task :start => :conf do - unless god_running? + if god_running? + puts `#{god} start resque` + else puts `#{god} -c #{config_file} -P #{pid_file} -l #{log_file}` save_md5 end @@ -31,7 +33,7 @@ namespace :resque do Process.daemon(true, false) # Stop everything - Rake::Task['resque:stop'].invoke + Rake::Task['resque:terminate'].invoke # Start again Rake::Task['resque:start'].invoke @@ -44,8 +46,13 @@ namespace :resque do end end - desc 'Stop Resque workers and quit God' + desc 'Stop Resque workers' task :stop do + puts `#{god} stop resque` + end + + desc 'Stop Resque workers and quit God' + task :terminate do puts `#{god} terminate` end @@ -70,7 +77,11 @@ namespace :resque do end def god_running? - File.exists?(pid_file) + File.exists?(pid_file) && Process.kill(0, File.read(pid_file).to_i) + rescue Errno::ESRCH + false + rescue Errno::EPERM + true end def god_stopped?