2014-01-14 22:22:40 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorSetupCheckDaemons extends PhabricatorSetupCheck {
|
|
|
|
|
|
|
|
protected function executeChecks() {
|
|
|
|
|
|
|
|
$task_daemon = id(new PhabricatorDaemonLogQuery())
|
|
|
|
->setViewer(PhabricatorUser::getOmnipotentUser())
|
|
|
|
->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)
|
|
|
|
->withDaemonClasses(array('PhabricatorTaskmasterDaemon'))
|
|
|
|
->setLimit(1)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
if (!$task_daemon) {
|
|
|
|
$doc_href = PhabricatorEnv::getDocLink(
|
2014-03-17 23:01:31 +01:00
|
|
|
'Managing Daemons with phd');
|
2014-01-14 22:22:40 +01:00
|
|
|
|
|
|
|
$summary = pht(
|
|
|
|
'You must start the Phabricator daemons to send email, rebuild '.
|
|
|
|
'search indexes, and do other background processing.');
|
|
|
|
|
|
|
|
$message = pht(
|
|
|
|
'The Phabricator daemons are not running, so Phabricator will not '.
|
|
|
|
'be able to perform background processing (including sending email, '.
|
|
|
|
'rebuilding search indexes, importing commits, cleaning up old data, '.
|
2014-09-05 21:26:58 +02:00
|
|
|
'and running builds).'.
|
2014-01-14 22:22:40 +01:00
|
|
|
"\n\n".
|
|
|
|
'Use %s to start daemons. See %s for more information.',
|
|
|
|
phutil_tag('tt', array(), 'bin/phd start'),
|
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $doc_href,
|
2014-10-07 15:01:04 +02:00
|
|
|
'target' => '_blank',
|
2014-01-14 22:22:40 +01:00
|
|
|
),
|
|
|
|
pht('Managing Daemons with phd')));
|
|
|
|
|
|
|
|
$this->newIssue('daemons.not-running')
|
|
|
|
->setShortName(pht('Daemons Not Running'))
|
|
|
|
->setName(pht('Phabricator Daemons Are Not Running'))
|
|
|
|
->setSummary($summary)
|
|
|
|
->setMessage($message)
|
|
|
|
->addCommand('phabricator/ $ ./bin/phd start');
|
|
|
|
}
|
|
|
|
|
2014-12-23 17:11:44 +01:00
|
|
|
$phd_user = PhabricatorEnv::getEnvConfig('phd.user');
|
2014-08-22 23:52:36 +02:00
|
|
|
$environment_hash = PhabricatorEnv::calculateEnvironmentHash();
|
|
|
|
$all_daemons = id(new PhabricatorDaemonLogQuery())
|
|
|
|
->setViewer(PhabricatorUser::getOmnipotentUser())
|
|
|
|
->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)
|
|
|
|
->execute();
|
|
|
|
foreach ($all_daemons as $daemon) {
|
2014-12-23 17:11:44 +01:00
|
|
|
|
|
|
|
if ($phd_user) {
|
|
|
|
if ($daemon->getRunningAsUser() != $phd_user) {
|
|
|
|
$doc_href = PhabricatorEnv::getDocLink(
|
|
|
|
'Managing Daemons with phd');
|
|
|
|
|
|
|
|
$summary = pht(
|
|
|
|
'At least one daemon is currently running as a different '.
|
|
|
|
'user than configured in the Phabricator phd.user setting');
|
|
|
|
|
|
|
|
$message = pht(
|
|
|
|
'A daemon is running as user %s while the Phabricator config '.
|
|
|
|
'specifies phd.user to be %s.'.
|
|
|
|
"\n\n".
|
|
|
|
'Either adjust phd.user to match %s or start '.
|
|
|
|
'the daemons as the correct user. '.
|
|
|
|
"\n\n".
|
|
|
|
'phd Daemons will try to '.
|
|
|
|
'use sudo to start as the configured user. '.
|
|
|
|
'Make sure that the user who starts phd has the correct '.
|
|
|
|
'sudo permissions to start phd daemons as %s',
|
|
|
|
phutil_tag('tt', array(), $daemon->getRunningAsUser()),
|
|
|
|
phutil_tag('tt', array(), $phd_user),
|
|
|
|
phutil_tag('tt', array(), $daemon->getRunningAsUser()),
|
|
|
|
phutil_tag('tt', array(), $phd_user));
|
|
|
|
|
|
|
|
$this->newIssue('daemons.run-as-different-user')
|
|
|
|
->setName(pht('Daemons are running as the wrong user'))
|
|
|
|
->setSummary($summary)
|
|
|
|
->setMessage($message)
|
|
|
|
->addCommand('phabricator/ $ ./bin/phd restart');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-22 23:52:36 +02:00
|
|
|
if ($daemon->getEnvHash() != $environment_hash) {
|
|
|
|
$doc_href = PhabricatorEnv::getDocLink(
|
|
|
|
'Managing Daemons with phd');
|
|
|
|
|
|
|
|
$summary = pht(
|
2014-09-05 21:27:20 +02:00
|
|
|
'At least one daemon is currently running with different '.
|
|
|
|
'configuration than the Phabricator web application.');
|
2014-08-22 23:52:36 +02:00
|
|
|
|
|
|
|
$message = pht(
|
2014-09-05 21:27:20 +02:00
|
|
|
'At least one daemon is currently running with a different '.
|
|
|
|
'configuration (config checksum %s) than the web application '.
|
|
|
|
'(config checksum %s).'.
|
2014-08-22 23:52:36 +02:00
|
|
|
"\n\n".
|
2014-09-05 21:27:20 +02:00
|
|
|
'This usually means that you have just made a configuration change '.
|
|
|
|
'from the web UI, but have not yet restarted the daemons. You '.
|
|
|
|
'need to restart the daemons after making configuration changes '.
|
|
|
|
'so they will pick up the new values: until you do, they will '.
|
|
|
|
'continue operating with the old settings.'.
|
|
|
|
"\n\n".
|
|
|
|
'(If you plan to make more changes, you can restart the daemons '.
|
|
|
|
'once after you finish making all of your changes.)'.
|
|
|
|
"\n\n".
|
|
|
|
'Use %s to restart daemons. You can find a list of running daemons '.
|
|
|
|
'in the %s, which will also help you identify which daemon (or '.
|
|
|
|
'daemons) have divergent configuration. For more information about '.
|
|
|
|
'managing the daemons, see %s in the documentation.'.
|
|
|
|
"\n\n".
|
|
|
|
'This can also happen if you use the %s environmental variable to '.
|
|
|
|
'choose a configuration file, but the daemons run with a different '.
|
|
|
|
'value than the web application. If restarting the daemons does '.
|
|
|
|
'not resolve this issue and you use %s to select configuration, '.
|
|
|
|
'check that it is set consistently.'.
|
|
|
|
"\n\n".
|
|
|
|
'A third possible cause is that you run several machines, and '.
|
|
|
|
'the %s configuration file differs between them. This file is '.
|
|
|
|
'updated when you edit configuration from the CLI with %s. If '.
|
|
|
|
'restarting the daemons does not resolve this issue and you '.
|
|
|
|
'run multiple machines, check that all machines have identical '.
|
|
|
|
'%s configuration files.'.
|
|
|
|
"\n\n".
|
|
|
|
'This issue is not severe, but usually indicates that something '.
|
|
|
|
'is not configured the way you expect, and may cause the daemons '.
|
|
|
|
'to exhibit different behavior than the web application does.',
|
|
|
|
|
|
|
|
phutil_tag('tt', array(), substr($daemon->getEnvHash(), 0, 12)),
|
|
|
|
phutil_tag('tt', array(), substr($environment_hash, 0, 12)),
|
2014-08-22 23:52:36 +02:00
|
|
|
phutil_tag('tt', array(), 'bin/phd restart'),
|
2014-08-27 20:35:21 +02:00
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/daemon/',
|
2014-10-07 15:01:04 +02:00
|
|
|
'target' => '_blank',
|
2014-08-27 20:35:21 +02:00
|
|
|
),
|
|
|
|
pht('Daemon Console')),
|
2014-08-22 23:52:36 +02:00
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $doc_href,
|
2014-10-07 15:01:04 +02:00
|
|
|
'target' => '_blank',
|
2014-08-22 23:52:36 +02:00
|
|
|
),
|
2014-09-05 21:27:20 +02:00
|
|
|
pht('Managing Daemons with phd')),
|
|
|
|
phutil_tag('tt', array(), 'PHABRICATOR_ENV'),
|
|
|
|
phutil_tag('tt', array(), 'PHABRICATOR_ENV'),
|
|
|
|
phutil_tag('tt', array(), 'phabricator/conf/local/local.json'),
|
|
|
|
phutil_tag('tt', array(), 'bin/config'),
|
|
|
|
phutil_tag('tt', array(), 'phabricator/conf/local/local.json'));
|
2014-08-22 23:52:36 +02:00
|
|
|
|
|
|
|
$this->newIssue('daemons.need-restarting')
|
2014-09-05 21:27:20 +02:00
|
|
|
->setName(pht('Daemons and Web Have Different Config'))
|
2014-08-22 23:52:36 +02:00
|
|
|
->setSummary($summary)
|
|
|
|
->setMessage($message)
|
|
|
|
->addCommand('phabricator/ $ ./bin/phd restart');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-01-14 22:22:40 +01:00
|
|
|
}
|
2014-08-22 23:52:36 +02:00
|
|
|
|
2014-01-14 22:22:40 +01:00
|
|
|
}
|