Refactors $_ENV to getenv

This commit is contained in:
David Abdemoulaie 2010-12-10 17:30:28 -08:00
parent 27758b47be
commit f0a4990105

View File

@ -1,43 +1,47 @@
<?php <?php
if(empty($_ENV)) { $QUEUE = getenv('QUEUE');
die("\$_ENV does not seem to be available. Ensure 'E' is in your variables_order php.ini setting\n"); if(empty($QUEUE)) {
}
if(empty($_ENV['QUEUE'])) {
die("Set QUEUE env var containing the list of queues to work.\n"); die("Set QUEUE env var containing the list of queues to work.\n");
} }
if(!empty($_ENV['APP_INCLUDE'])) { $APP_INCLUDE = getenv('APP_INCLUDE');
if(!file_exists($_ENV['APP_INCLUDE'])) { if(!$APP_INCLUDE) {
die('APP_INCLUDE ('.$_ENV['APP_INCLUDE'].") does not exist.\n"); if(!file_exists($APP_INCLUDE)) {
die('APP_INCLUDE ('.$APP_INCLUDE.") does not exist.\n");
} }
require_once $_ENV['APP_INCLUDE']; require_once $APP_INCLUDE;
} }
require 'lib/Resque.php'; require 'lib/Resque.php';
require 'lib/Resque/Worker.php'; require 'lib/Resque/Worker.php';
if(!empty($_ENV['REDIS_BACKEND'])) { $REDIS_BACKEND = getenv('REDIS_BACKEND');
Resque::setBackend($_ENV['REDIS_BACKEND']); if(!empty($REDIS_BACKEND)) {
Resque::setBackend($REDIS_BACKEND);
} }
$logLevel = 0; $logLevel = 0;
if(!empty($_ENV['LOGGING']) || !empty($_ENV['VERBOSE'])) { $LOGGING = getenv('LOGGING');
$VERBOSE = getenv('VERBOSE');
$VVERBOSE = getenv('VVERBOSE');
if(!empty($LOGGING) || !empty($VERBOSE)) {
$logLevel = Resque_Worker::LOG_NORMAL; $logLevel = Resque_Worker::LOG_NORMAL;
} }
else if(!empty($_ENV['VVERBOSE'])) { else if(!empty($VVERBOSE)) {
$logLevel = Resque_Worker::LOG_VERBOSE; $logLevel = Resque_Worker::LOG_VERBOSE;
} }
$interval = 5; $interval = 5;
if(!empty($_ENV['INTERVAL'])) { $INTERVAL = getenv('INTERVAL');
$interval = $_ENV['INTERVAL']; if(!empty($INTERVAL)) {
$interval = $INTERVAL;
} }
$count = 1; $count = 1;
if(!empty($_ENV['COUNT']) && $_ENV['COUNT'] > 1) { $COUNT = getenv('COUNT');
$count = $_ENV['COUNT']; if(!empty($COUNT) && $COUNT > 1) {
$count = $COUNT;
} }
if($count > 1) { if($count > 1) {
@ -48,7 +52,7 @@ if($count > 1) {
} }
// Child, start the worker // Child, start the worker
else if(!$pid) { else if(!$pid) {
$queues = explode(',', $_ENV['QUEUE']); $queues = explode(',', $QUEUE);
$worker = new Resque_Worker($queues); $worker = new Resque_Worker($queues);
$worker->logLevel = $logLevel; $worker->logLevel = $logLevel;
fwrite(STDOUT, '*** Starting worker '.$worker."\n"); fwrite(STDOUT, '*** Starting worker '.$worker."\n");
@ -59,7 +63,7 @@ if($count > 1) {
} }
// Start a single worker // Start a single worker
else { else {
$queues = explode(',', $_ENV['QUEUE']); $queues = explode(',', $QUEUE);
$worker = new Resque_Worker($queues); $worker = new Resque_Worker($queues);
$worker->logLevel = $logLevel; $worker->logLevel = $logLevel;
fwrite(STDOUT, '*** Starting worker '.$worker."\n"); fwrite(STDOUT, '*** Starting worker '.$worker."\n");