Path: blob/master/src/applications/config/check/PhabricatorDaemonsSetupCheck.php
12256 views
<?php12final class PhabricatorDaemonsSetupCheck extends PhabricatorSetupCheck {34public function getDefaultGroup() {5return self::GROUP_IMPORTANT;6}78protected function executeChecks() {910try {11$task_daemons = id(new PhabricatorDaemonLogQuery())12->setViewer(PhabricatorUser::getOmnipotentUser())13->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)14->withDaemonClasses(array('PhabricatorTaskmasterDaemon'))15->setLimit(1)16->execute();1718$no_daemons = !$task_daemons;19} catch (Exception $ex) {20// Just skip this warning if the query fails for some reason.21$no_daemons = false;22}2324if ($no_daemons) {25$doc_href = PhabricatorEnv::getDoclink('Managing Daemons with phd');2627$summary = pht(28'You must start the daemons to send email, rebuild search indexes, '.29'and do other background processing.');3031$message = pht(32'The daemons are not running, background processing (including '.33'sending email, rebuilding search indexes, importing commits, '.34'cleaning up old data, and running builds) can not be performed.'.35"\n\n".36'Use %s to start daemons. See %s for more information.',37phutil_tag('tt', array(), 'bin/phd start'),38phutil_tag(39'a',40array(41'href' => $doc_href,42'target' => '_blank',43),44pht('Managing Daemons with phd')));4546$this->newIssue('daemons.not-running')47->setShortName(pht('Daemons Not Running'))48->setName(pht('Daemons Are Not Running'))49->setSummary($summary)50->setMessage($message)51->addCommand('$ ./bin/phd start');52}5354$expect_user = PhabricatorEnv::getEnvConfig('phd.user');55if ($expect_user !== null && strlen($expect_user)) {5657try {58$all_daemons = id(new PhabricatorDaemonLogQuery())59->setViewer(PhabricatorUser::getOmnipotentUser())60->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)61->execute();62} catch (Exception $ex) {63// If this query fails for some reason, just skip this check.64$all_daemons = array();65}6667foreach ($all_daemons as $daemon) {68$actual_user = $daemon->getRunningAsUser();69if ($actual_user == $expect_user) {70continue;71}7273$summary = pht(74'At least one daemon is currently running as the wrong user.');7576$message = pht(77'A daemon is running as user %s, but daemons should be '.78'running as %s.'.79"\n\n".80'Either adjust the configuration setting %s or restart the '.81'daemons. Daemons should attempt to run as the proper user when '.82'restarted.',83phutil_tag('tt', array(), $actual_user),84phutil_tag('tt', array(), $expect_user),85phutil_tag('tt', array(), 'phd.user'));8687$this->newIssue('daemons.run-as-different-user')88->setName(pht('Daemon Running as Wrong User'))89->setSummary($summary)90->setMessage($message)91->addPhabricatorConfig('phd.user')92->addCommand('$ ./bin/phd restart');9394break;95}96}97}9899}100101102