From 18ee51ac7b1fd47b8ed9451866d1fe1256736060 Mon Sep 17 00:00:00 2001 From: Vasyl Vavrychuk Date: Thu, 27 Sep 2012 01:33:29 +0300 Subject: [PATCH] use available api to check daemon status Summary: Replace executing 'ps aux' with usage of available api to control daemons PhabricatorDaemonControl. This fixes isPullDaemonRunningOnThisMachine returning wrong status under Fedora & lighttpd & SELinux because SELinux with default settings blocked getting all processes in 'ps aux'. Test Plan: start stop daemon and check repository app Reviewers: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3557 --- .../PhabricatorRepositoryController.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/applications/repository/controller/PhabricatorRepositoryController.php b/src/applications/repository/controller/PhabricatorRepositoryController.php index dcb62685f9..f8c82f9188 100644 --- a/src/applications/repository/controller/PhabricatorRepositoryController.php +++ b/src/applications/repository/controller/PhabricatorRepositoryController.php @@ -37,12 +37,15 @@ abstract class PhabricatorRepositoryController extends PhabricatorController { return $response->setContent($page->render()); } - private function isPullDaemonRunningOnThisMachine() { - - // This is sort of hacky, but should probably work. - - list($stdout) = execx('ps auxwww'); - return preg_match('/PhabricatorRepositoryPullLocalDaemon/', $stdout); + private function isPullDaemonRunning() { + $control = new PhabricatorDaemonControl(); + $daemons = $control->loadRunningDaemons(); + foreach ($daemons as $daemon) { + if ($daemon->isRunning() && + $daemon->getName() == 'PhabricatorRepositoryPullLocalDaemon') + return true; + } + return false; } protected function renderDaemonNotice() { @@ -60,7 +63,7 @@ abstract class PhabricatorRepositoryController extends PhabricatorController { "{$documentation}."; try { - $daemon_running = $this->isPullDaemonRunningOnThisMachine(); + $daemon_running = $this->isPullDaemonRunning(); if ($daemon_running) { return null; }