Skip to content

Commit

Permalink
Apply old PR 328
Browse files Browse the repository at this point in the history
  • Loading branch information
danhunsaker committed Dec 11, 2018
1 parent bd514b8 commit 28d46d5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/Resque.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class Resque
*/
protected static $redisDatabase = 0;

/**
* @var string auth of Redis database
*/
protected static $auth;

/**
* Given a host/port combination separated by a colon, set it as
* the redis server that Resque will talk to.
Expand All @@ -37,11 +42,13 @@ class Resque
* and returns a Resque_Redis instance, or
* a nested array of servers with host/port pairs.
* @param int $database
* @param string $auth
*/
public static function setBackend($server, $database = 0)
public static function setBackend($server, $database = 0, $auth = null)
{
self::$redisServer = $server;
self::$redisDatabase = $database;
self::$auth = $auth;
self::$redis = null;
}

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

if (!empty(self::$auth)) {
self::$redis->auth(self::$auth);
}

return self::$redis;
}

Expand Down
4 changes: 4 additions & 0 deletions lib/Resque/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public function work($interval = Resque::DEFAULT_INTERVAL, $blocking = false)
$this->updateProcLine('Starting');
$this->startup();

if(function_exists('pcntl_signal_dispatch')) {
pcntl_signal_dispatch();
}

while(true) {
if($this->shutdown) {
break;
Expand Down

0 comments on commit 28d46d5

Please sign in to comment.