From a85452b8d6ecdc77bb4e0f1b1fab4a95e1f8f75b Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Thu, 15 Jan 2015 06:56:38 +1100 Subject: [PATCH] Allow daemons to be terminated in the absence of MySQL Summary: Fixes T6842. Allow the daemons to always be terminated, even if MySQL is down. I was hoping to be able to optionally enable this behavior with the `--force` flag, but this seems messy. Test Plan: ```lang=bash > ./bin/phd start Freeing active task leases... Freed 1 task lease(s). Preparing to launch daemons. NOTE: Logs will appear in '/var/tmp/phd/log/daemons.log'. Starting daemons as phd Launching daemon "PhabricatorRepositoryPullLocalDaemon". Starting daemons as phd Launching daemon "PhabricatorGarbageCollectorDaemon". Starting daemons as phd Launching daemon "PhabricatorTaskmasterDaemon". Done. > service mysql stop mysql stop/waiting > ./bin/phd stop Interrupting daemon 'PhabricatorRepositoryPullLocalDaemon' (4263)... Interrupting daemon 'PhabricatorGarbageCollectorDaemon' (4271)... Interrupting daemon 'PhabricatorTaskmasterDaemon' (4287)... Daemon 4263 exited. Daemon 4271 exited. Daemon 4287 exited. ``` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6842 Differential Revision: https://secure.phabricator.com/D11385 --- .../daemon/control/PhabricatorDaemonReference.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/infrastructure/daemon/control/PhabricatorDaemonReference.php b/src/infrastructure/daemon/control/PhabricatorDaemonReference.php index e2fa340054..983b54598b 100644 --- a/src/infrastructure/daemon/control/PhabricatorDaemonReference.php +++ b/src/infrastructure/daemon/control/PhabricatorDaemonReference.php @@ -32,11 +32,16 @@ final class PhabricatorDaemonReference { $ref->pid = idx($dict, 'pid'); $ref->start = idx($dict, 'start'); - $ref->daemonLog = id(new PhabricatorDaemonLog())->loadOneWhere( - 'daemon = %s AND pid = %d AND dateCreated = %d', - $ref->name, - $ref->pid, - $ref->start); + try { + $ref->daemonLog = id(new PhabricatorDaemonLog())->loadOneWhere( + 'daemon = %s AND pid = %d AND dateCreated = %d', + $ref->name, + $ref->pid, + $ref->start); + } catch (AphrontQueryException $ex) { + // Ignore the exception. We want to be able to terminate the daemons, + // even if MySQL is down. + } return $ref; }