1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

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
This commit is contained in:
Vasyl Vavrychuk 2012-09-27 01:33:29 +03:00
parent f1d4755c61
commit 18ee51ac7b

View file

@ -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 {
"<strong>{$documentation}</strong>.";
try {
$daemon_running = $this->isPullDaemonRunningOnThisMachine();
$daemon_running = $this->isPullDaemonRunning();
if ($daemon_running) {
return null;
}