Permalink
Browse files

Added a PREFIX environment variable to set the Resque prefix

  • Loading branch information...
1 parent cd85e8b commit 01c291f367cb5392146268dee4cb68abec6912c1 @ruudk ruudk committed Mar 26, 2013
Showing with 14 additions and 0 deletions.
  1. +8 −0 README.md
  2. +6 −0 bin/resque
View
8 README.md
@@ -223,6 +223,13 @@ the `COUNT` environment variable:
$ 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 ###
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
* jjfrey
* scragg0x
+* ruudk
View
6 bin/resque
@@ -71,6 +71,12 @@ if(!empty($COUNT) && $COUNT > 1) {
$count = $COUNT;
}
+$PREFIX = getenv('PREFIX');
+if(!empty($PREFIX)) {
+ fwrite(STDOUT, '*** Prefix set to '.$PREFIX."\n");
+ Resque_Redis::prefix($PREFIX);
+}
+
if($count > 1) {
for($i = 0; $i < $count; ++$i) {
$pid = Resque::fork();

0 comments on commit 01c291f

Please sign in to comment.