From 01c291f367cb5392146268dee4cb68abec6912c1 Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Tue, 26 Mar 2013 13:59:33 +0100 Subject: [PATCH] Added a PREFIX environment variable to set the Resque prefix --- README.md | 8 ++++++++ bin/resque | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/README.md b/README.md index 8e11988..bfdc302 100644 --- a/README.md +++ b/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 diff --git a/bin/resque b/bin/resque index 78befad..2b605ce 100644 --- a/bin/resque +++ b/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();