Added a PREFIX environment variable to set the Resque prefix

This commit is contained in:
Ruud Kamphuis 2013-03-26 13:59:33 +01:00
parent cd85e8be85
commit 01c291f367
2 changed files with 14 additions and 0 deletions

View File

@ -223,6 +223,13 @@ the `COUNT` environment variable:
$ COUNT=5 bin/resque $ COUNT=5 bin/resque
### Custom prefix ###
When you have multiple apps using the same Redis database it is better to
use a custom prefix to separate the Resque data:
$ PREFIX=my-app-name bin/resque
### Forking ### ### Forking ###
Similarly to the Ruby versions, supported platforms will immediately Similarly to the Ruby versions, supported platforms will immediately
@ -371,3 +378,4 @@ Called after a job has been queued using the `Resque::enqueue` method. Arguments
* Matt Heath * Matt Heath
* jjfrey * jjfrey
* scragg0x * scragg0x
* ruudk

View File

@ -71,6 +71,12 @@ if(!empty($COUNT) && $COUNT > 1) {
$count = $COUNT; $count = $COUNT;
} }
$PREFIX = getenv('PREFIX');
if(!empty($PREFIX)) {
fwrite(STDOUT, '*** Prefix set to '.$PREFIX."\n");
Resque_Redis::prefix($PREFIX);
}
if($count > 1) { if($count > 1) {
for($i = 0; $i < $count; ++$i) { for($i = 0; $i < $count; ++$i) {
$pid = Resque::fork(); $pid = Resque::fork();