From e96408361e4abbd6ac9c1a36e688fa3a10586250 Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Fri, 18 Sep 2015 18:33:06 -0700 Subject: [PATCH] Move the daemons code from bin/rq-mgr to code/rq-mgr.rb --- bin/rq-mgr | 30 +----------------------------- code/rq-mgr.rb | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 29 deletions(-) create mode 100644 code/rq-mgr.rb diff --git a/bin/rq-mgr b/bin/rq-mgr index a437900..5f1653c 100755 --- a/bin/rq-mgr +++ b/bin/rq-mgr @@ -7,32 +7,4 @@ RQ_DIR=$(cd "$(dirname "$0")/.." && pwd) exec 3>/dev/null 4>/dev/null # Here we go -exec /usr/bin/env ruby -C "$RQ_DIR" -I . -e " - require 'vendor/environment' - require 'daemons' - - require 'code/queuemgr' - - options = { - :app_name => 'queuemgr', - :dir_mode => :normal, - :dir => '$RQ_DIR/config', - :multiple => false, - :mode => :exec, - :backtrace => true, - :monitor => false, - :log_dir => '$RQ_DIR/log', - :log_output => false, - } - - Daemons.run_proc('queuemgr', options) do - Dir.chdir('$RQ_DIR') - - require 'logger' - \$log = Logger.new('log/queuemgr.log') - \$log.level = Logger::INFO - \$log.progname = \$0 - - RQ::QueueMgr.new.run! - end -" -- $@ +exec /usr/bin/env ruby -C "$RQ_DIR" -I . code/rq-mgr.rb $@ diff --git a/code/rq-mgr.rb b/code/rq-mgr.rb new file mode 100644 index 0000000..f82a26a --- /dev/null +++ b/code/rq-mgr.rb @@ -0,0 +1,31 @@ +require 'vendor/environment' +require 'daemons' + +require 'code/queuemgr' + +options = { + :app_name => 'queuemgr', + :dir_mode => :normal, + :dir => './config', + :multiple => false, + :mode => :exec, + :backtrace => true, + :monitor => false, + :log_dir => './log', + :log_output => false, +} + +# Daemons will chdir to / but there are many assumptions +# in code/ that it is running from the RQ basedir. +RQ_DIR = Dir.pwd + +Daemons.run_proc('queuemgr', options) do + Dir.chdir RQ_DIR + + require 'logger' + $log = Logger.new('log/queuemgr.log') + $log.level = Logger::INFO + $log.progname = $0 + + RQ::QueueMgr.new.run! +end