Skip to content

Commit

Permalink
Don't totally fallover if gearman isn't running when it should be.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaneMcC committed Nov 10, 2018
1 parent 7eeab06 commit 72a32ae
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ function checkDBAlive() {

if ($config['jobserver']['type'] == 'gearman') {
$gmc = new GearmanClient();
$gmc->addServer($config['jobserver']['host'], $config['jobserver']['port']);
$gmc->setTimeout(5000);
try {
$gmc->addServer($config['jobserver']['host'], $config['jobserver']['port']);
$gmc->setTimeout(5000);
} catch (Exception $e) {
$config['jobserver']['type'] == 'none';
$gmc == null;
}
}

if ($gmc !== null) {
HookManager::get()->addHook('send_mail', function($to, $subject, $message, $htmlmessage = NULL) use ($gmc) {
@$gmc->doBackground('sendmail', json_encode(['to' => $to, 'subject' => $subject, 'message' => $message, 'htmlmessage' => $htmlmessage]));
});
Expand Down

0 comments on commit 72a32ae

Please sign in to comment.