From 420d6426f96077d162b178ae8f3800f01bb00f5a Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Tue, 17 Jul 2012 13:39:32 -0400 Subject: [PATCH] 'phd status' should exit with non-zero if daemons are not running. 'phd status' may be invoked by tools (such as puppet) which need to make automated decisions about whether to start/restart the daemon. To enable this, 'phd status' now exits with 0 if all daemons are running, 1 if no daemons are running, and 2 if some (but not all) daemons are running. --- src/infrastructure/daemon/PhabricatorDaemonControl.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/infrastructure/daemon/PhabricatorDaemonControl.php b/src/infrastructure/daemon/PhabricatorDaemonControl.php index 33059d4cbe..b2b2f0cd79 100644 --- a/src/infrastructure/daemon/PhabricatorDaemonControl.php +++ b/src/infrastructure/daemon/PhabricatorDaemonControl.php @@ -41,9 +41,10 @@ final class PhabricatorDaemonControl { if (!$daemons) { echo "There are no running Phabricator daemons.\n"; - return 0; + return 1; } + $status = 0; printf( "%-5s\t%-24s\t%s\n", "PID", @@ -52,6 +53,7 @@ final class PhabricatorDaemonControl { foreach ($daemons as $daemon) { $name = $daemon->getName(); if (!$daemon->isRunning()) { + $status = 2; $name = ' '.$name; if ($daemon->getPIDFile()) { Filesystem::remove($daemon->getPIDFile()); @@ -66,7 +68,7 @@ final class PhabricatorDaemonControl { $name); } - return 0; + return $status; } public function executeStopCommand($pids = null) {