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:
parent
3bc391fbc7
commit
6f246bd351
5 changed files with 53 additions and 0 deletions
2
resources/sql/autopatches/20140822.daemonenvhash.sql
Normal file
2
resources/sql/autopatches/20140822.daemonenvhash.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_daemon.daemon_log
|
||||
ADD COLUMN `envHash` CHAR(40) NOT NULL DEFAULT '' AFTER `dateModified`;
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -15,6 +15,7 @@ final class PhabricatorDaemonLog extends PhabricatorDaemonDAO
|
|||
protected $pid;
|
||||
protected $argv;
|
||||
protected $explicitArgv = array();
|
||||
protected $envHash;
|
||||
protected $status;
|
||||
|
||||
public function getConfiguration() {
|
||||
|
|
9
src/infrastructure/env/PhabricatorEnv.php
vendored
9
src/infrastructure/env/PhabricatorEnv.php
vendored
|
@ -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 )---------------------------------------------- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue