1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 00:10:57 +01:00

Daemons - add a config check for out of date daemon environment

Summary: Fixes T4881.

Test Plan: made a config change, saw the issue, restarted daemons and it went away

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4881

Differential Revision: https://secure.phabricator.com/D10339
This commit is contained in:
Bob Trahan 2014-08-22 14:52:36 -07:00
parent 3bc391fbc7
commit 6f246bd351
5 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_daemon.daemon_log
ADD COLUMN `envHash` CHAR(40) NOT NULL DEFAULT '' AFTER `dateModified`;

View file

@ -31,6 +31,7 @@ final class PhabricatorSetupCheckDaemons extends PhabricatorSetupCheck {
'a',
array(
'href' => $doc_href,
'target' => '_blank'
),
pht('Managing Daemons with phd')));
@ -42,5 +43,44 @@ final class PhabricatorSetupCheckDaemons extends PhabricatorSetupCheck {
->addCommand('phabricator/ $ ./bin/phd start');
}
$environment_hash = PhabricatorEnv::calculateEnvironmentHash();
$all_daemons = id(new PhabricatorDaemonLogQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)
->execute();
foreach ($all_daemons as $daemon) {
if ($daemon->getEnvHash() != $environment_hash) {
$doc_href = PhabricatorEnv::getDocLink(
'Managing Daemons with phd');
$summary = pht(
'You should restart the daemons. Their configuration is out of '.
'date.');
$message = pht(
'The Phabricator daemons are running with an out of date '.
'configuration. If you are making multiple configuration changes, '.
'you only need to restart the daemons once after the last change.'.
"\n\n".
'Use %s to restart daemons. See %s for more information.',
phutil_tag('tt', array(), 'bin/phd restart'),
phutil_tag(
'a',
array(
'href' => $doc_href,
'target' => '_blank'
),
pht('Managing Daemons with phd')));
$this->newIssue('daemons.need-restarting')
->setShortName(pht('Daemons Need Restarting'))
->setName(pht('Phabricator Daemons Need Restarting'))
->setSummary($summary)
->setMessage($message)
->addCommand('phabricator/ $ ./bin/phd restart');
break;
}
}
}
}

View file

@ -39,6 +39,7 @@ final class PhabricatorDaemonEventListener extends PhabricatorEventListener {
->setDaemon($event->getValue('daemonClass'))
->setHost(php_uname('n'))
->setPID(getmypid())
->setEnvHash(PhabricatorEnv::calculateEnvironmentHash())
->setStatus(PhabricatorDaemonLog::STATUS_RUNNING)
->setArgv($event->getValue('argv'))
->setExplicitArgv($event->getValue('explicitArgv'))

View file

@ -15,6 +15,7 @@ final class PhabricatorDaemonLog extends PhabricatorDaemonDAO
protected $pid;
protected $argv;
protected $explicitArgv = array();
protected $envHash;
protected $status;
public function getConfiguration() {

View file

@ -221,6 +221,15 @@ final class PhabricatorEnv {
return $env;
}
public static function calculateEnvironmentHash() {
$keys = array_keys(self::getAllConfigKeys());
$values = array();
foreach ($keys as $key) {
$values[$key] = self::getEnvConfigIfExists($key);
}
return PhabricatorHash::digest(json_encode($values));
}
/* -( Reading Configuration )---------------------------------------------- */