Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / config / check / PhabricatorDaemonsSetupCheck.php
blob7ef44dc384ead9a7cf328b58f21fba0bd13965db
1 <?php
3 final class PhabricatorDaemonsSetupCheck extends PhabricatorSetupCheck {
5 public function getDefaultGroup() {
6 return self::GROUP_IMPORTANT;
9 protected function executeChecks() {
11 try {
12 $task_daemons = id(new PhabricatorDaemonLogQuery())
13 ->setViewer(PhabricatorUser::getOmnipotentUser())
14 ->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)
15 ->withDaemonClasses(array('PhabricatorTaskmasterDaemon'))
16 ->setLimit(1)
17 ->execute();
19 $no_daemons = !$task_daemons;
20 } catch (Exception $ex) {
21 // Just skip this warning if the query fails for some reason.
22 $no_daemons = false;
25 if ($no_daemons) {
26 $doc_href = PhabricatorEnv::getDoclink('Managing Daemons with phd');
28 $summary = pht(
29 'You must start the Phabricator daemons to send email, rebuild '.
30 'search indexes, and do other background processing.');
32 $message = pht(
33 'The Phabricator daemons are not running, so Phabricator will not '.
34 'be able to perform background processing (including sending email, '.
35 'rebuilding search indexes, importing commits, cleaning up old data, '.
36 'and running builds).'.
37 "\n\n".
38 'Use %s to start daemons. See %s for more information.',
39 phutil_tag('tt', array(), 'bin/phd start'),
40 phutil_tag(
41 'a',
42 array(
43 'href' => $doc_href,
44 'target' => '_blank',
46 pht('Managing Daemons with phd')));
48 $this->newIssue('daemons.not-running')
49 ->setShortName(pht('Daemons Not Running'))
50 ->setName(pht('Phabricator Daemons Are Not Running'))
51 ->setSummary($summary)
52 ->setMessage($message)
53 ->addCommand('phabricator/ $ ./bin/phd start');
56 $expect_user = PhabricatorEnv::getEnvConfig('phd.user');
57 if (strlen($expect_user)) {
59 try {
60 $all_daemons = id(new PhabricatorDaemonLogQuery())
61 ->setViewer(PhabricatorUser::getOmnipotentUser())
62 ->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)
63 ->execute();
64 } catch (Exception $ex) {
65 // If this query fails for some reason, just skip this check.
66 $all_daemons = array();
69 foreach ($all_daemons as $daemon) {
70 $actual_user = $daemon->getRunningAsUser();
71 if ($actual_user == $expect_user) {
72 continue;
75 $summary = pht(
76 'At least one daemon is currently running as the wrong user.');
78 $message = pht(
79 'A daemon is running as user %s, but daemons should be '.
80 'running as %s.'.
81 "\n\n".
82 'Either adjust the configuration setting %s or restart the '.
83 'daemons. Daemons should attempt to run as the proper user when '.
84 'restarted.',
85 phutil_tag('tt', array(), $actual_user),
86 phutil_tag('tt', array(), $expect_user),
87 phutil_tag('tt', array(), 'phd.user'));
89 $this->newIssue('daemons.run-as-different-user')
90 ->setName(pht('Daemon Running as Wrong User'))
91 ->setSummary($summary)
92 ->setMessage($message)
93 ->addPhabricatorConfig('phd.user')
94 ->addCommand('phabricator/ $ ./bin/phd restart');
96 break;