mirror of
https://github.com/idanoo/php-resque.git
synced 2024-11-22 00:11:53 +00:00
Fixes bin/resque
This commit is contained in:
parent
2794dd54a9
commit
ffff86c40c
104
bin/resque
104
bin/resque
@ -3,40 +3,40 @@
|
||||
|
||||
// Find and initialize Composer
|
||||
$files = array(
|
||||
__DIR__ . '/../../vendor/autoload.php',
|
||||
__DIR__ . '/../../../autoload.php',
|
||||
__DIR__ . '/../../../../autoload.php',
|
||||
__DIR__ . '/../vendor/autoload.php',
|
||||
__DIR__ . '/../../vendor/autoload.php',
|
||||
__DIR__ . '/../../../autoload.php',
|
||||
__DIR__ . '/../../../../autoload.php',
|
||||
__DIR__ . '/../vendor/autoload.php',
|
||||
);
|
||||
|
||||
$found = false;
|
||||
foreach ($files as $file) {
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
break;
|
||||
}
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('Composer\Autoload\ClassLoader', false)) {
|
||||
die(
|
||||
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
|
||||
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
|
||||
'php composer.phar install' . PHP_EOL
|
||||
);
|
||||
die(
|
||||
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
|
||||
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
|
||||
'php composer.phar install' . PHP_EOL
|
||||
);
|
||||
}
|
||||
|
||||
$QUEUE = getenv('QUEUE');
|
||||
if(empty($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");
|
||||
}
|
||||
|
||||
$REDIS_BACKEND = getenv('REDIS_BACKEND');
|
||||
$REDIS_BACKEND_DB = getenv('REDIS_BACKEND_DB');
|
||||
if(!empty($REDIS_BACKEND)) {
|
||||
if (empty($REDIS_BACKEND_DB))
|
||||
Resque::setBackend($REDIS_BACKEND);
|
||||
else
|
||||
Resque::setBackend($REDIS_BACKEND, $REDIS_BACKEND_DB);
|
||||
if (empty($REDIS_BACKEND_DB))
|
||||
Resque::setBackend($REDIS_BACKEND);
|
||||
else
|
||||
Resque::setBackend($REDIS_BACKEND, $REDIS_BACKEND_DB);
|
||||
}
|
||||
|
||||
$logLevel = 0;
|
||||
@ -44,31 +44,33 @@ $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($VVERBOSE)) {
|
||||
$logLevel = Resque_Worker::LOG_VERBOSE;
|
||||
$logLevel = Resque_Worker::LOG_VERBOSE;
|
||||
}
|
||||
|
||||
$APP_INCLUDE = getenv('APP_INCLUDE');
|
||||
if($APP_INCLUDE) {
|
||||
if(!file_exists($APP_INCLUDE)) {
|
||||
die('APP_INCLUDE ('.$APP_INCLUDE.") does not exist.\n");
|
||||
}
|
||||
if(!file_exists($APP_INCLUDE)) {
|
||||
die('APP_INCLUDE ('.$APP_INCLUDE.") does not exist.\n");
|
||||
}
|
||||
|
||||
require_once $APP_INCLUDE;
|
||||
require_once $APP_INCLUDE;
|
||||
}
|
||||
|
||||
$BLOCKING = getenv('BLOCKING') !== FALSE;
|
||||
|
||||
$interval = 5;
|
||||
$INTERVAL = getenv('INTERVAL');
|
||||
if(!empty($INTERVAL)) {
|
||||
$interval = $INTERVAL;
|
||||
$interval = $INTERVAL;
|
||||
}
|
||||
|
||||
$count = 1;
|
||||
$COUNT = getenv('COUNT');
|
||||
if(!empty($COUNT) && $COUNT > 1) {
|
||||
$count = $COUNT;
|
||||
$count = $COUNT;
|
||||
}
|
||||
|
||||
$PREFIX = getenv('PREFIX');
|
||||
@ -78,35 +80,35 @@ if(!empty($PREFIX)) {
|
||||
}
|
||||
|
||||
if($count > 1) {
|
||||
for($i = 0; $i < $count; ++$i) {
|
||||
$pid = Resque::fork();
|
||||
if($pid == -1) {
|
||||
die("Could not fork worker ".$i."\n");
|
||||
}
|
||||
// Child, start the worker
|
||||
else if(!$pid) {
|
||||
$queues = explode(',', $QUEUE);
|
||||
$worker = new Resque_Worker($queues);
|
||||
$worker->logLevel = $logLevel;
|
||||
fwrite(STDOUT, '*** Starting worker '.$worker."\n");
|
||||
$worker->work($interval);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for($i = 0; $i < $count; ++$i) {
|
||||
$pid = Resque::fork();
|
||||
if($pid == -1) {
|
||||
die("Could not fork worker ".$i."\n");
|
||||
}
|
||||
// Child, start the worker
|
||||
else if(!$pid) {
|
||||
$queues = explode(',', $QUEUE);
|
||||
$worker = new Resque_Worker($queues);
|
||||
$worker->logLevel = $logLevel;
|
||||
fwrite(STDOUT, '*** Starting worker '.$worker."\n");
|
||||
$worker->work($interval, $BLOCKING);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Start a single worker
|
||||
else {
|
||||
$queues = explode(',', $QUEUE);
|
||||
$worker = new Resque_Worker($queues);
|
||||
$worker->logLevel = $logLevel;
|
||||
$queues = explode(',', $QUEUE);
|
||||
$worker = new Resque_Worker($queues);
|
||||
$worker->logLevel = $logLevel;
|
||||
|
||||
$PIDFILE = getenv('PIDFILE');
|
||||
if ($PIDFILE) {
|
||||
file_put_contents($PIDFILE, getmypid()) or
|
||||
die('Could not write PID information to ' . $PIDFILE);
|
||||
}
|
||||
$PIDFILE = getenv('PIDFILE');
|
||||
if ($PIDFILE) {
|
||||
file_put_contents($PIDFILE, getmypid()) or
|
||||
die('Could not write PID information to ' . $PIDFILE);
|
||||
}
|
||||
|
||||
fwrite(STDOUT, '*** Starting worker '.$worker."\n");
|
||||
$worker->work($interval);
|
||||
fwrite(STDOUT, '*** Starting worker '.$worker."\n");
|
||||
$worker->work($interval, $BLOCKING);
|
||||
}
|
||||
?>
|
105
bin/resque.php
105
bin/resque.php
@ -1,105 +0,0 @@
|
||||
<?php
|
||||
// Find and initialize Composer
|
||||
$files = array(
|
||||
__DIR__ . '/../../vendor/autoload.php',
|
||||
__DIR__ . '/../../../autoload.php',
|
||||
__DIR__ . '/../../../../autoload.php',
|
||||
__DIR__ . '/../vendor/autoload.php',
|
||||
);
|
||||
|
||||
$found = false;
|
||||
foreach ($files as $file) {
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('Composer\Autoload\ClassLoader', false)) {
|
||||
die(
|
||||
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
|
||||
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
|
||||
'php composer.phar install' . PHP_EOL
|
||||
);
|
||||
}
|
||||
|
||||
$QUEUE = getenv('QUEUE');
|
||||
if(empty($QUEUE)) {
|
||||
die("Set QUEUE env var containing the list of queues to work.\n");
|
||||
}
|
||||
|
||||
$REDIS_BACKEND = getenv('REDIS_BACKEND');
|
||||
$REDIS_BACKEND_DB = getenv('REDIS_BACKEND_DB');
|
||||
if(!empty($REDIS_BACKEND)) {
|
||||
if (empty($REDIS_BACKEND_DB))
|
||||
Resque::setBackend($REDIS_BACKEND);
|
||||
else
|
||||
Resque::setBackend($REDIS_BACKEND, $REDIS_BACKEND_DB);
|
||||
}
|
||||
|
||||
$logLevel = 0;
|
||||
$LOGGING = getenv('LOGGING');
|
||||
$VERBOSE = getenv('VERBOSE');
|
||||
$VVERBOSE = getenv('VVERBOSE');
|
||||
if(!empty($LOGGING) || !empty($VERBOSE)) {
|
||||
$logLevel = Resque_Worker::LOG_NORMAL;
|
||||
}
|
||||
else if(!empty($VVERBOSE)) {
|
||||
$logLevel = Resque_Worker::LOG_VERBOSE;
|
||||
}
|
||||
|
||||
$BLOCKING = getenv('BLOCKING') !== FALSE;
|
||||
|
||||
$APP_INCLUDE = getenv('APP_INCLUDE');
|
||||
if($APP_INCLUDE) {
|
||||
if(!file_exists($APP_INCLUDE)) {
|
||||
die('APP_INCLUDE ('.$APP_INCLUDE.") does not exist.\n");
|
||||
}
|
||||
|
||||
require_once $APP_INCLUDE;
|
||||
}
|
||||
|
||||
$interval = 5;
|
||||
$INTERVAL = getenv('INTERVAL');
|
||||
if(!empty($INTERVAL)) {
|
||||
$interval = $INTERVAL;
|
||||
}
|
||||
|
||||
$count = 1;
|
||||
$COUNT = getenv('COUNT');
|
||||
if(!empty($COUNT) && $COUNT > 1) {
|
||||
$count = $COUNT;
|
||||
}
|
||||
|
||||
if($count > 1) {
|
||||
for($i = 0; $i < $count; ++$i) {
|
||||
$pid = Resque::fork();
|
||||
if($pid == -1) {
|
||||
die("Could not fork worker ".$i."\n");
|
||||
}
|
||||
// Child, start the worker
|
||||
else if(!$pid) {
|
||||
$queues = explode(',', $QUEUE);
|
||||
$worker = new Resque_Worker($queues);
|
||||
$worker->logLevel = $logLevel;
|
||||
fwrite(STDOUT, '*** Starting worker '.$worker."\n");
|
||||
$worker->work($interval, $BLOCKING);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Start a single worker
|
||||
else {
|
||||
$queues = explode(',', $QUEUE);
|
||||
$worker = new Resque_Worker($queues);
|
||||
$worker->logLevel = $logLevel;
|
||||
|
||||
$PIDFILE = getenv('PIDFILE');
|
||||
if ($PIDFILE) {
|
||||
file_put_contents($PIDFILE, getmypid()) or
|
||||
die('Could not write PID information to ' . $PIDFILE);
|
||||
}
|
||||
|
||||
fwrite(STDOUT, '*** Starting worker '.$worker."\n");
|
||||
$worker->work($interval, $BLOCKING);
|
||||
}
|
Loading…
Reference in New Issue
Block a user