Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php b/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php
index 004ce3a84e..f4c7ba60c9 100644
--- a/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php
+++ b/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php
@@ -1,182 +1,180 @@
<?php
final class PhabricatorDaemonLogViewController
extends PhabricatorDaemonController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$log = id(new PhabricatorDaemonLogQuery())
->setViewer($viewer)
->withIDs(array($id))
->setAllowStatusWrites(true)
->executeOne();
if (!$log) {
return new Aphront404Response();
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Daemon %s', $log->getID()));
$crumbs->setBorder(true);
$header = id(new PHUIHeaderView())
->setHeader($log->getDaemon())
->setHeaderIcon('fa-pied-piper-alt');
$tag = id(new PHUITagView())
->setType(PHUITagView::TYPE_STATE);
$status = $log->getStatus();
switch ($status) {
case PhabricatorDaemonLog::STATUS_UNKNOWN:
$color = 'orange';
$name = pht('Unknown');
$icon = 'fa-warning';
break;
case PhabricatorDaemonLog::STATUS_RUNNING:
$color = 'green';
$name = pht('Running');
$icon = 'fa-rocket';
break;
case PhabricatorDaemonLog::STATUS_DEAD:
$color = 'red';
$name = pht('Dead');
$icon = 'fa-times';
break;
case PhabricatorDaemonLog::STATUS_WAIT:
$color = 'blue';
$name = pht('Waiting');
$icon = 'fa-clock-o';
break;
case PhabricatorDaemonLog::STATUS_EXITING:
$color = 'yellow';
$name = pht('Exiting');
$icon = 'fa-check';
break;
case PhabricatorDaemonLog::STATUS_EXITED:
$color = 'bluegrey';
$name = pht('Exited');
$icon = 'fa-check';
break;
}
$header->setStatus($icon, $color, $name);
$properties = $this->buildPropertyListView($log);
$object_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Daemon Details'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->addPropertyList($properties);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(array(
$object_box,
));
return $this->newPage()
->setTitle(pht('Daemon Log'))
->setCrumbs($crumbs)
->appendChild($view);
}
private function buildPropertyListView(PhabricatorDaemonLog $daemon) {
$request = $this->getRequest();
$viewer = $request->getUser();
$view = id(new PHUIPropertyListView())
->setUser($viewer);
$id = $daemon->getID();
$c_epoch = $daemon->getDateCreated();
$u_epoch = $daemon->getDateModified();
$unknown_time = PhabricatorDaemonLogQuery::getTimeUntilUnknown();
$dead_time = PhabricatorDaemonLogQuery::getTimeUntilDead();
$wait_time = PhutilDaemonHandle::getWaitBeforeRestart();
$details = null;
$status = $daemon->getStatus();
switch ($status) {
case PhabricatorDaemonLog::STATUS_RUNNING:
$details = pht(
'This daemon is running normally and reported a status update '.
'recently (within %s).',
phutil_format_relative_time($unknown_time));
break;
case PhabricatorDaemonLog::STATUS_UNKNOWN:
$details = pht(
'This daemon has not reported a status update recently (within %s). '.
'It may have exited abruptly. After %s, it will be presumed dead.',
phutil_format_relative_time($unknown_time),
phutil_format_relative_time($dead_time));
break;
case PhabricatorDaemonLog::STATUS_DEAD:
$details = pht(
'This daemon did not report a status update for %s. It is '.
'presumed dead. Usually, this indicates that the daemon was '.
'killed or otherwise exited abruptly with an error. You may '.
'need to restart it.',
phutil_format_relative_time($dead_time));
break;
case PhabricatorDaemonLog::STATUS_WAIT:
$details = pht(
'This daemon is running normally and reported a status update '.
- 'recently (within %s). However, it encountered an error while '.
- 'doing work and is waiting a little while (%s) to resume '.
- 'processing. After encountering an error, daemons wait before '.
- 'resuming work to avoid overloading services.',
- phutil_format_relative_time($unknown_time),
- phutil_format_relative_time($wait_time));
+ 'recently (within %s). The process is currently waiting to '.
+ 'restart, either because it is hibernating or because it '.
+ 'encountered an error.',
+ phutil_format_relative_time($unknown_time));
break;
case PhabricatorDaemonLog::STATUS_EXITING:
$details = pht('This daemon is shutting down gracefully.');
break;
case PhabricatorDaemonLog::STATUS_EXITED:
$details = pht('This daemon exited normally and is no longer running.');
break;
}
$view->addProperty(pht('Status Details'), $details);
$view->addProperty(pht('Daemon Class'), $daemon->getDaemon());
$view->addProperty(pht('Host'), $daemon->getHost());
$view->addProperty(pht('PID'), $daemon->getPID());
$view->addProperty(pht('Running as'), $daemon->getRunningAsUser());
$view->addProperty(pht('Started'), phabricator_datetime($c_epoch, $viewer));
$view->addProperty(
pht('Seen'),
pht(
'%s ago (%s)',
phutil_format_relative_time(time() - $u_epoch),
phabricator_datetime($u_epoch, $viewer)));
$argv = $daemon->getArgv();
if (is_array($argv)) {
$argv = implode("\n", $argv);
}
$view->addProperty(
pht('Argv'),
phutil_tag(
'textarea',
array(
'style' => 'width: 100%; height: 12em;',
),
$argv));
$view->addProperty(
pht('View Full Logs'),
phutil_tag(
'tt',
array(),
"phabricator/ $ ./bin/phd log --id {$id}"));
return $view;
}
}
diff --git a/src/infrastructure/daemon/overseer/PhabricatorDaemonOverseerModule.php b/src/infrastructure/daemon/overseer/PhabricatorDaemonOverseerModule.php
index 608151c348..be5ebec79e 100644
--- a/src/infrastructure/daemon/overseer/PhabricatorDaemonOverseerModule.php
+++ b/src/infrastructure/daemon/overseer/PhabricatorDaemonOverseerModule.php
@@ -1,54 +1,60 @@
<?php
/**
* Overseer module.
*
* The primary purpose of this overseer module is to poll for configuration
* changes and reload daemons when the configuration changes.
*/
final class PhabricatorDaemonOverseerModule
extends PhutilDaemonOverseerModule {
private $configVersion;
public function shouldReloadDaemons() {
if ($this->shouldThrottle('reload', 10)) {
return false;
}
return $this->updateConfigVersion();
}
/**
* Calculate a version number for the current Phabricator configuration.
*
* The version number has no real meaning and does not provide any real
* indication of whether a configuration entry has been changed. The config
* version is intended to be a rough indicator that "something has changed",
* which indicates to the overseer that the daemons should be reloaded.
*
* @return int
*/
private function loadConfigVersion() {
$conn_r = id(new PhabricatorConfigEntry())->establishConnection('r');
return head(queryfx_one(
$conn_r,
'SELECT MAX(id) FROM %T',
id(new PhabricatorConfigTransaction())->getTableName()));
}
/**
* Check and update the configuration version.
*
* @return bool True if the daemons should restart, otherwise false.
*/
private function updateConfigVersion() {
$old_version = $this->configVersion;
$new_version = $this->loadConfigVersion();
$this->configVersion = $new_version;
+ // Don't trigger a reload if we're loading the config for the very
+ // first time.
+ if ($old_version === null) {
+ return false;
+ }
+
return ($old_version != $new_version);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jul 3, 8:06 PM (5 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
166330
Default Alt Text
(8 KB)

Event Timeline