From 22a4912d9dc1e5fedf5e3d8361b32d048bea7fa8 Mon Sep 17 00:00:00 2001 From: Merkushin Date: Thu, 12 Dec 2013 09:48:34 +0600 Subject: [PATCH] =?UTF-8?q?fix(god)=20fast=20restart=20with=20nowait=20?= =?UTF-8?q?=D0=9F=D1=80=D0=B8=20=D1=80=D0=B5=D1=81=D1=82=D0=B0=D1=80=D1=82?= =?UTF-8?q?=D0=B5=20=D0=BD=D0=B5=20=D0=B2=D1=8B=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B0=D0=B5=D0=BC=20=D0=B8=20=D0=B2=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B0=D0=B5=D0=BC=20god,=20=D0=B0=20=D0=BF=D0=BE=D0=B4=D1=81?= =?UTF-8?q?=D0=BE=D0=B2=D1=8B=D0=B2=D0=B0=D0=B5=D0=BC=20=D0=B5=D0=BC=D1=83?= =?UTF-8?q?=20=D0=BD=D0=BE=D0=B2=D1=83=D1=8E=20=D0=BA=D0=BE=D0=BD=D1=84?= =?UTF-8?q?=D0=B8=D0=B3=D1=83.=20=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D1=81=D0=BC=D0=B5=D0=BD=D0=B5=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B0=20=D0=B1=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D1=88=D0=B5=20=D0=BD=D0=B5=D1=82=20=D0=BD=D0=B5=D0=BE=D0=B1?= =?UTF-8?q?=D1=85=D0=BE=D0=B4=D0=B8=D0=BC=D0=BE=D1=81=D1=82=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B6=D0=B8=D0=B4=D0=B0=D1=82=D1=8C=D1=81=D1=8F,=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BA=D0=B0=20=D0=B4=D0=BB=D0=B8=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=B4=D0=B6=D0=BE=D0=B1=D1=8B=20=D0=B1=D1=83=D0=B4?= =?UTF-8?q?=D1=83=D1=82=20=D0=B7=D0=B0=D0=B2=D0=B5=D1=80=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D1=8B=20=D0=B8=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=BC=20=D0=B1=D1=83=D0=B4=D1=83=D1=82=20(?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5)=D0=B7=D0=B0=D0=BF=D1=83=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BE=D1=87=D0=B5=D1=80=D0=B5=D0=B4=D0=B8.=20?= =?UTF-8?q?=D0=95=D1=81=D1=82=D1=8C=20=D0=BD=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D1=88=D0=BE=D0=B9=20=D0=BC=D0=B8=D0=BD=D1=83=D1=81,=20=D0=B3?= =?UTF-8?q?=D0=BB=D0=BE=D0=B1=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BE?= =?UTF-8?q?=D0=BF=D1=86=D0=B8=D0=B8,=20=D1=82=D0=B0=D0=BA=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BA=D0=B0=D0=BA=20pid=5Ffile=5Fdirectory=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D0=B1=D1=83=D0=B4=D1=83=D1=82=20=D0=BF=D0=B5=D1=80=D0=B5=D1=87?= =?UTF-8?q?=D0=B8=D1=82=D0=B0=D0=BD=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/resque/integration/tasks/resque.rake | 39 +----------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/lib/resque/integration/tasks/resque.rake b/lib/resque/integration/tasks/resque.rake index 9a50632..cc4a9ed 100644 --- a/lib/resque/integration/tasks/resque.rake +++ b/lib/resque/integration/tasks/resque.rake @@ -1,7 +1,5 @@ # coding: utf-8 -require 'digest/md5' - namespace :resque do desc 'Generate God configuration file' task :conf => :environment do @@ -16,7 +14,6 @@ namespace :resque do puts `#{god} start resque` else puts `#{god} -c #{config_file} -P #{pid_file} -l #{log_file}` - save_md5 end end @@ -24,25 +21,8 @@ namespace :resque do task :restart => :conf do if god_stopped? Rake::Task['resque:start'].invoke - elsif config_changed? - puts 'Resque config changed, God should be stopped and started again.' - - # it can take long, we'll run it in background - puts 'Stopping god. It can take a while...' - - Process.daemon(true, false) - - # Stop everything - Rake::Task['resque:terminate'].invoke - - # Start again - Rake::Task['resque:start'].invoke else - puts 'Restarting god. Executing in background. It can take a while...' - - Process.daemon(true, false) - - `#{god} restart resque` + puts `#{god} load #{config_file} stop && #{god} restart resque` end end @@ -99,21 +79,4 @@ namespace :resque do def config_file Rails.root.join('config/resque.god').to_s end - - # Returns true if config file was changed since last deploy - def config_changed? - config_md5 != current_md5 - end - - def current_md5 - Resque.redis.get('config:md5') - end - - def save_md5 - Resque.redis.set('config:md5', config_md5) - end - - def config_md5 - Digest::MD5.hexdigest(File.read(config_file)) - end end \ No newline at end of file