Look for a var in the bin/resque script to allow override

This commit is contained in:
Rockstar04 2013-06-25 12:10:08 -07:00
parent 726e58a297
commit 5cef885a06

View File

@ -50,8 +50,6 @@ else if(!empty($VVERBOSE)) {
$logLevel = true; $logLevel = true;
} }
$logger = new Resque_Log($logLevel);
$APP_INCLUDE = getenv('APP_INCLUDE'); $APP_INCLUDE = getenv('APP_INCLUDE');
if($APP_INCLUDE) { if($APP_INCLUDE) {
if(!file_exists($APP_INCLUDE)) { if(!file_exists($APP_INCLUDE)) {
@ -61,6 +59,12 @@ if($APP_INCLUDE) {
require_once $APP_INCLUDE; require_once $APP_INCLUDE;
} }
// See if the APP_INCLUDE containes a logger object,
// If none exists, fallback to internal logger
if (!isset($logger) && !is_object($logger)) {
$logger = new Resque_Log($logLevel);
}
$BLOCKING = getenv('BLOCKING') !== FALSE; $BLOCKING = getenv('BLOCKING') !== FALSE;
$interval = 5; $interval = 5;
@ -92,7 +96,7 @@ if($count > 1) {
else if(!$pid) { else if(!$pid) {
$queues = explode(',', $QUEUE); $queues = explode(',', $QUEUE);
$worker = new Resque_Worker($queues); $worker = new Resque_Worker($queues);
$worker->setLogger(new Resque_Log($logLevel)); $worker->setLogger($logger);
$logger->log(Psr\Log\LogLevel::NOTICE, 'Starting worker {worker}', array('worker' => $worker)); $logger->log(Psr\Log\LogLevel::NOTICE, 'Starting worker {worker}', array('worker' => $worker));
$worker->work($interval, $BLOCKING); $worker->work($interval, $BLOCKING);
break; break;
@ -103,7 +107,7 @@ if($count > 1) {
else { else {
$queues = explode(',', $QUEUE); $queues = explode(',', $QUEUE);
$worker = new Resque_Worker($queues); $worker = new Resque_Worker($queues);
$worker->setLogger(new Resque_Log($logLevel)); $worker->setLogger($logger);
$PIDFILE = getenv('PIDFILE'); $PIDFILE = getenv('PIDFILE');
if ($PIDFILE) { if ($PIDFILE) {