Skip to content

Commit 6421998

Browse files
committed
Apply old PR 243
Closes chrisboulton/php-resque#243
1 parent dec0d9c commit 6421998

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/Resque/Worker.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@ public function work($interval = Resque::DEFAULT_INTERVAL, $blocking = false)
157157
break;
158158
}
159159

160+
// is redis still alive?
161+
try {
162+
if (Resque::redis()->ping() === false) {
163+
throw new CredisException('redis ping() failed');
164+
}
165+
} catch (CredisException $e) {
166+
$this->logger->log(Psr\Log\LogLevel::ERROR, 'redis went away. trying to reconnect');
167+
Resque::$redis = null;
168+
usleep($interval * 1000000);
169+
continue;
170+
}
171+
160172
// Attempt to find and reserve a job
161173
$job = false;
162174
if(!$this->paused) {

0 commit comments

Comments
 (0)