-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added locale resque start scripts for resque and resque-scheduler.
After talking to @danhunsaker who explained that the scripts in php-resque were mend as examples rather than actual starter scripts. I added these to BBCResqueBundle it self. This allows us to customize the start process. You can see the discussion here: chrisboulton/php-resque#123
- Loading branch information
ulrik nielsen
committed
Aug 15, 2013
1 parent
594b9d5
commit 492593b
Showing
4 changed files
with
149 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
$QUEUE = getenv('QUEUE'); | ||
if (empty($QUEUE)) { | ||
die("Set QUEUE env var containing the list of queues to work.\n"); | ||
} | ||
|
||
require_once __DIR__."/../../../../../autoload.php"; | ||
|
||
$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; | ||
} | ||
|
||
$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 = pcntl_fork(); | ||
if ($pid == -1) { | ||
die("Could not fork worker ".$i."\n"); | ||
} else if (!$pid) { | ||
// Child, start the worker | ||
$queues = explode(',', $QUEUE); | ||
$worker = new Resque_Worker($queues); | ||
$worker->logLevel = $logLevel; | ||
fwrite(STDOUT, '*** Starting worker '.$worker."\n"); | ||
$worker->work($interval); | ||
break; | ||
} | ||
} | ||
} else { | ||
// Start a single worker | ||
$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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
require_once __DIR__."/../../../../../autoload.php"; | ||
|
||
// Look for an environment variable with | ||
$RESQUE_PHP = getenv('RESQUE_PHP'); | ||
if (!empty($RESQUE_PHP)) { | ||
require_once $RESQUE_PHP; | ||
} | ||
|
||
$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); | ||
} | ||
} | ||
|
||
// Set log level for resque-scheduler | ||
$logLevel = 0; | ||
$LOGGING = getenv('LOGGING'); | ||
$VERBOSE = getenv('VERBOSE'); | ||
$VVERBOSE = getenv('VVERBOSE'); | ||
if (!empty($LOGGING) || !empty($VERBOSE)) { | ||
$logLevel = ResqueScheduler_Worker::LOG_NORMAL; | ||
} else if (!empty($VVERBOSE)) { | ||
$logLevel = ResqueScheduler_Worker::LOG_VERBOSE; | ||
} | ||
|
||
// Check for jobs every $interval seconds | ||
$interval = 5; | ||
$INTERVAL = getenv('INTERVAL'); | ||
if (!empty($INTERVAL)) { | ||
$interval = $INTERVAL; | ||
} | ||
|
||
// Load the user's application if one exists | ||
$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; | ||
} | ||
|
||
$worker = new ResqueScheduler_Worker(); | ||
$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 scheduler worker\n"); | ||
$worker->work($interval); |