Remove product literal strings in "pht()", part 4
[phabricator.git] / src / applications / config / check / PhabricatorDaemonsSetupCheck.php
blob608bac675ef6437814d91522714796ff77d83b63
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 daemons to send email, rebuild search indexes, '.
30 'and do other background processing.');
32 $message = pht(
33 'The daemons are not running, background processing (including '.
34 'sending email, rebuilding search indexes, importing commits, '.
35 'cleaning up old data, and running builds) can not be performed.'.
36 "\n\n".
37 'Use %s to start daemons. See %s for more information.',
38 phutil_tag('tt', array(), 'bin/phd start'),
39 phutil_tag(
40 'a',
41 array(
42 'href' => $doc_href,
43 'target' => '_blank',
45 pht('Managing Daemons with phd')));
47 $this->newIssue('daemons.not-running')
48 ->setShortName(pht('Daemons Not Running'))
49 ->setName(pht('Daemons Are Not Running'))
50 ->setSummary($summary)
51 ->setMessage($message)
52 ->addCommand('$ ./bin/phd start');
55 $expect_user = PhabricatorEnv::getEnvConfig('phd.user');
56 if (strlen($expect_user)) {
58 try {
59 $all_daemons = id(new PhabricatorDaemonLogQuery())
60 ->setViewer(PhabricatorUser::getOmnipotentUser())
61 ->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)
62 ->execute();
63 } catch (Exception $ex) {
64 // If this query fails for some reason, just skip this check.
65 $all_daemons = array();
68 foreach ($all_daemons as $daemon) {
69 $actual_user = $daemon->getRunningAsUser();
70 if ($actual_user == $expect_user) {
71 continue;
74 $summary = pht(
75 'At least one daemon is currently running as the wrong user.');
77 $message = pht(
78 'A daemon is running as user %s, but daemons should be '.
79 'running as %s.'.
80 "\n\n".
81 'Either adjust the configuration setting %s or restart the '.
82 'daemons. Daemons should attempt to run as the proper user when '.
83 'restarted.',
84 phutil_tag('tt', array(), $actual_user),
85 phutil_tag('tt', array(), $expect_user),
86 phutil_tag('tt', array(), 'phd.user'));
88 $this->newIssue('daemons.run-as-different-user')
89 ->setName(pht('Daemon Running as Wrong User'))
90 ->setSummary($summary)
91 ->setMessage($message)
92 ->addPhabricatorConfig('phd.user')
93 ->addCommand('$ ./bin/phd restart');
95 break;