mirror of
https://github.com/idanoo/php-resque.git
synced 2024-11-22 00:11:53 +00:00
Clean up bin/resque file
This commit is contained in:
parent
e0914efdd5
commit
2a3dcd8537
22
bin/resque
22
bin/resque
@ -2,12 +2,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Find and initialize Composer
|
// Find and initialize Composer
|
||||||
$files = array(
|
$files = [
|
||||||
__DIR__ . '/../../vendor/autoload.php',
|
__DIR__ . '/../../vendor/autoload.php',
|
||||||
__DIR__ . '/../../../autoload.php',
|
__DIR__ . '/../../../autoload.php',
|
||||||
__DIR__ . '/../../../../autoload.php',
|
__DIR__ . '/../../../../autoload.php',
|
||||||
__DIR__ . '/../vendor/autoload.php',
|
__DIR__ . '/../vendor/autoload.php',
|
||||||
);
|
];
|
||||||
|
|
||||||
$found = false;
|
$found = false;
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
@ -53,8 +53,7 @@ $VERBOSE = getenv('VERBOSE');
|
|||||||
$VVERBOSE = getenv('VVERBOSE');
|
$VVERBOSE = getenv('VVERBOSE');
|
||||||
if (!empty($LOGGING) || !empty($VERBOSE)) {
|
if (!empty($LOGGING) || !empty($VERBOSE)) {
|
||||||
$logLevel = true;
|
$logLevel = true;
|
||||||
}
|
} else if (!empty($VVERBOSE)) {
|
||||||
else if(!empty($VVERBOSE)) {
|
|
||||||
$logLevel = true;
|
$logLevel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +88,7 @@ if(!empty($COUNT) && $COUNT > 1) {
|
|||||||
|
|
||||||
$PREFIX = getenv('PREFIX');
|
$PREFIX = getenv('PREFIX');
|
||||||
if (!empty($PREFIX)) {
|
if (!empty($PREFIX)) {
|
||||||
$logger->log(Psr\Log\LogLevel::INFO, 'Prefix set to {prefix}', array('prefix' => $PREFIX));
|
$logger->log(Psr\Log\LogLevel::INFO, 'Prefix set to {prefix}', ['prefix' => $PREFIX]);
|
||||||
Resque_Redis::prefix($PREFIX);
|
Resque_Redis::prefix($PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,22 +96,20 @@ if($count > 1) {
|
|||||||
for ($i = 0; $i < $count; ++$i) {
|
for ($i = 0; $i < $count; ++$i) {
|
||||||
$pid = Resque::fork();
|
$pid = Resque::fork();
|
||||||
if ($pid === false || $pid === -1) {
|
if ($pid === false || $pid === -1) {
|
||||||
$logger->log(Psr\Log\LogLevel::EMERGENCY, 'Could not fork worker {count}', array('count' => $i));
|
$logger->log(Psr\Log\LogLevel::EMERGENCY, 'Could not fork worker {count}', ['count' => $i]);
|
||||||
die();
|
die();
|
||||||
}
|
} elseif (!$pid) {
|
||||||
// Child, start the worker
|
// Child, start the worker
|
||||||
else if(!$pid) {
|
|
||||||
$queues = explode(',', $QUEUE);
|
$queues = explode(',', $QUEUE);
|
||||||
$worker = new Resque_Worker($queues);
|
$worker = new Resque_Worker($queues);
|
||||||
$worker->setLogger($logger);
|
$worker->setLogger($logger);
|
||||||
$logger->log(Psr\Log\LogLevel::NOTICE, 'Starting worker {worker}', array('worker' => $worker));
|
$logger->log(Psr\Log\LogLevel::NOTICE, 'Starting worker {worker}', ['worker' => $worker]);
|
||||||
$worker->work($interval, $BLOCKING);
|
$worker->work($interval, $BLOCKING);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
// Start a single worker
|
// Start a single worker
|
||||||
else {
|
|
||||||
$queues = explode(',', $QUEUE);
|
$queues = explode(',', $QUEUE);
|
||||||
$worker = new Resque_Worker($queues);
|
$worker = new Resque_Worker($queues);
|
||||||
$worker->setLogger($logger);
|
$worker->setLogger($logger);
|
||||||
@ -123,7 +120,6 @@ else {
|
|||||||
die('Could not write PID information to ' . $PIDFILE);
|
die('Could not write PID information to ' . $PIDFILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
$logger->log(Psr\Log\LogLevel::NOTICE, 'Starting worker {worker}', array('worker' => $worker));
|
$logger->log(Psr\Log\LogLevel::NOTICE, 'Starting worker {worker}', ['worker' => $worker]);
|
||||||
$worker->work($interval, $BLOCKING);
|
$worker->work($interval, $BLOCKING);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user