From c2874945c87f1cadcdc4b70c4d4fc36f922e6507 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 27 Aug 2014 11:35:21 -0700 Subject: [PATCH] Daemons - add status of environment to daemon console, etc Summary: Shows the UI everywhere. Also asort() the keys before calculating the environment hash as that is probably an issue for someone at some point we just don't need to have. Ref T5968. Test Plan: Viewed the setup check and saw a link to the daemon console. Viewed the daemon console and saw the various stale config daemons. Clicked a daemon and saw a "stale config" header icon where expected. Restarted daemons and all of this went away. Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T5968 Differential Revision: https://secure.phabricator.com/D10367 --- .../config/check/PhabricatorSetupCheckDaemons.php | 9 ++++++++- .../PhabricatorDaemonLogViewController.php | 8 ++++++++ .../daemon/view/PhabricatorDaemonLogListView.php | 12 ++++++++++-- src/infrastructure/env/PhabricatorEnv.php | 2 ++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/applications/config/check/PhabricatorSetupCheckDaemons.php b/src/applications/config/check/PhabricatorSetupCheckDaemons.php index 8ea68debbe..9e02ac4ed9 100644 --- a/src/applications/config/check/PhabricatorSetupCheckDaemons.php +++ b/src/applications/config/check/PhabricatorSetupCheckDaemons.php @@ -62,8 +62,15 @@ final class PhabricatorSetupCheckDaemons extends PhabricatorSetupCheck { '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.', + 'Use %s to restart daemons. See the %s or %s for more information.', phutil_tag('tt', array(), 'bin/phd restart'), + phutil_tag( + 'a', + array( + 'href' => '/daemon/', + 'target' => '_blank' + ), + pht('Daemon Console')), phutil_tag( 'a', array( diff --git a/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php b/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php index ef6315bfc2..10ee28471d 100644 --- a/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php +++ b/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php @@ -64,6 +64,14 @@ final class PhabricatorDaemonLogViewController } $header->addTag($tag); + $env_hash = PhabricatorEnv::calculateEnvironmentHash(); + if ($log->getEnvHash() != $env_hash) { + $tag = id(new PHUITagView()) + ->setType(PHUITagView::TYPE_STATE) + ->setBackgroundColor(PHUITagView::COLOR_YELLOW) + ->setName(pht('Stale Config')); + $header->addTag($tag); + } $properties = $this->buildPropertyListView($log); diff --git a/src/applications/daemon/view/PhabricatorDaemonLogListView.php b/src/applications/daemon/view/PhabricatorDaemonLogListView.php index e9f7876d07..a1f668d480 100644 --- a/src/applications/daemon/view/PhabricatorDaemonLogListView.php +++ b/src/applications/daemon/view/PhabricatorDaemonLogListView.php @@ -17,6 +17,7 @@ final class PhabricatorDaemonLogListView extends AphrontView { throw new Exception('Call setUser() before rendering!'); } + $env_hash = PhabricatorEnv::calculateEnvironmentHash(); $list = new PHUIObjectItemListView(); foreach ($this->daemonLogs as $log) { $id = $log->getID(); @@ -31,8 +32,15 @@ final class PhabricatorDaemonLogListView extends AphrontView { $status = $log->getStatus(); switch ($status) { case PhabricatorDaemonLog::STATUS_RUNNING: - $item->setBarColor('green'); - $item->addAttribute(pht('This daemon is running.')); + if ($env_hash != $log->getEnvHash()) { + $item->setBarColor('yellow'); + $item->addAttribute(pht( + 'This daemon is running with an out of date configuration and '. + 'should be restarted.')); + } else { + $item->setBarColor('green'); + $item->addAttribute(pht('This daemon is running.')); + } break; case PhabricatorDaemonLog::STATUS_DEAD: $item->setBarColor('red'); diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php index d5e3237b88..a8f4dcec6b 100644 --- a/src/infrastructure/env/PhabricatorEnv.php +++ b/src/infrastructure/env/PhabricatorEnv.php @@ -223,6 +223,8 @@ final class PhabricatorEnv { public static function calculateEnvironmentHash() { $keys = array_keys(self::getAllConfigKeys()); + asort($keys); + $values = array(); foreach ($keys as $key) { $values[$key] = self::getEnvConfigIfExists($key);