Skip to content

Commit 28d46d5

Browse files
committed
Apply old PR 328
Closes chrisboulton/php-resque#328
1 parent bd514b8 commit 28d46d5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/Resque.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class Resque
2828
*/
2929
protected static $redisDatabase = 0;
3030

31+
/**
32+
* @var string auth of Redis database
33+
*/
34+
protected static $auth;
35+
3136
/**
3237
* Given a host/port combination separated by a colon, set it as
3338
* the redis server that Resque will talk to.
@@ -37,11 +42,13 @@ class Resque
3742
* and returns a Resque_Redis instance, or
3843
* a nested array of servers with host/port pairs.
3944
* @param int $database
45+
* @param string $auth
4046
*/
41-
public static function setBackend($server, $database = 0)
47+
public static function setBackend($server, $database = 0, $auth = null)
4248
{
4349
self::$redisServer = $server;
4450
self::$redisDatabase = $database;
51+
self::$auth = $auth;
4552
self::$redis = null;
4653
}
4754

@@ -62,6 +69,10 @@ public static function redis()
6269
self::$redis = new Resque_Redis(self::$redisServer, self::$redisDatabase);
6370
}
6471

72+
if (!empty(self::$auth)) {
73+
self::$redis->auth(self::$auth);
74+
}
75+
6576
return self::$redis;
6677
}
6778

lib/Resque/Worker.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ public function work($interval = Resque::DEFAULT_INTERVAL, $blocking = false)
152152
$this->updateProcLine('Starting');
153153
$this->startup();
154154

155+
if(function_exists('pcntl_signal_dispatch')) {
156+
pcntl_signal_dispatch();
157+
}
158+
155159
while(true) {
156160
if($this->shutdown) {
157161
break;

0 commit comments

Comments
 (0)