Page MenuHomePhorge

No OneTemporary

diff --git a/src/applications/daemon/controller/PhabricatorDaemonLogEventViewController.php b/src/applications/daemon/controller/PhabricatorDaemonLogEventViewController.php
index 2991b0b62b..772ee87fd1 100644
--- a/src/applications/daemon/controller/PhabricatorDaemonLogEventViewController.php
+++ b/src/applications/daemon/controller/PhabricatorDaemonLogEventViewController.php
@@ -1,49 +1,43 @@
<?php
final class PhabricatorDaemonLogEventViewController
extends PhabricatorDaemonController {
- private $id;
+ public function handleRequest(AphrontRequest $request) {
+ $id = $request->getURIData('id');
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
-
- $event = id(new PhabricatorDaemonLogEvent())->load($this->id);
+ $event = id(new PhabricatorDaemonLogEvent())->load($id);
if (!$event) {
return new Aphront404Response();
}
$event_view = id(new PhabricatorDaemonLogEventsView())
->setEvents(array($event))
->setUser($request->getUser())
->setCombinedLog(true)
->setShowFullMessage(true);
$log_panel = new PHUIObjectBoxView();
$log_panel->setHeaderText(pht('Combined Log'));
$log_panel->appendChild($event_view);
$daemon_id = $event->getLogID();
$crumbs = $this->buildApplicationCrumbs()
->addTextCrumb(
pht('Daemon %s', $daemon_id),
$this->getApplicationURI("log/{$daemon_id}/"))
->addTextCrumb(pht('Event %s', $event->getID()));
return $this->buildApplicationPage(
array(
$crumbs,
$log_panel,
),
array(
'title' => pht('Combined Daemon Log'),
));
}
}
diff --git a/src/applications/daemon/controller/PhabricatorDaemonLogListController.php b/src/applications/daemon/controller/PhabricatorDaemonLogListController.php
index 7b2324ae59..c1de0b892f 100644
--- a/src/applications/daemon/controller/PhabricatorDaemonLogListController.php
+++ b/src/applications/daemon/controller/PhabricatorDaemonLogListController.php
@@ -1,42 +1,41 @@
<?php
final class PhabricatorDaemonLogListController
extends PhabricatorDaemonController {
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
$pager = new AphrontCursorPagerView();
$pager->readFromRequest($request);
$logs = id(new PhabricatorDaemonLogQuery())
->setViewer($viewer)
->setAllowStatusWrites(true)
->executeWithCursorPager($pager);
$daemon_table = new PhabricatorDaemonLogListView();
$daemon_table->setUser($request->getUser());
$daemon_table->setDaemonLogs($logs);
$box = id(new PHUIObjectBoxView())
->setHeaderText(pht('All Daemons'))
->appendChild($daemon_table);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('All Daemons'));
$nav = $this->buildSideNavView();
$nav->selectFilter('log');
$nav->setCrumbs($crumbs);
$nav->appendChild($box);
$nav->appendChild($pager);
return $this->buildApplicationPage(
$nav,
array(
'title' => pht('All Daemons'),
));
}
}
diff --git a/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php b/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php
index baab0528e3..60bf290ae5 100644
--- a/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php
+++ b/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php
@@ -1,197 +1,191 @@
<?php
final class PhabricatorDaemonLogViewController
extends PhabricatorDaemonController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $user = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
$log = id(new PhabricatorDaemonLogQuery())
- ->setViewer($user)
- ->withIDs(array($this->id))
+ ->setViewer($viewer)
+ ->withIDs(array($id))
->setAllowStatusWrites(true)
->executeOne();
if (!$log) {
return new Aphront404Response();
}
$events = id(new PhabricatorDaemonLogEvent())->loadAllWhere(
'logID = %d ORDER BY id DESC LIMIT 1000',
$log->getID());
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Daemon %s', $log->getID()));
$header = id(new PHUIHeaderView())
->setHeader($log->getDaemon());
$tag = id(new PHUITagView())
->setType(PHUITagView::TYPE_STATE);
$status = $log->getStatus();
switch ($status) {
case PhabricatorDaemonLog::STATUS_UNKNOWN:
$tag->setBackgroundColor(PHUITagView::COLOR_ORANGE);
$tag->setName(pht('Unknown'));
break;
case PhabricatorDaemonLog::STATUS_RUNNING:
$tag->setBackgroundColor(PHUITagView::COLOR_GREEN);
$tag->setName(pht('Running'));
break;
case PhabricatorDaemonLog::STATUS_DEAD:
$tag->setBackgroundColor(PHUITagView::COLOR_RED);
$tag->setName(pht('Dead'));
break;
case PhabricatorDaemonLog::STATUS_WAIT:
$tag->setBackgroundColor(PHUITagView::COLOR_BLUE);
$tag->setName(pht('Waiting'));
break;
case PhabricatorDaemonLog::STATUS_EXITING:
$tag->setBackgroundColor(PHUITagView::COLOR_YELLOW);
$tag->setName(pht('Exiting'));
break;
case PhabricatorDaemonLog::STATUS_EXITED:
$tag->setBackgroundColor(PHUITagView::COLOR_GREY);
$tag->setName(pht('Exited'));
break;
}
$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);
$event_view = id(new PhabricatorDaemonLogEventsView())
- ->setUser($user)
+ ->setUser($viewer)
->setEvents($events);
$event_panel = new PHUIObjectBoxView();
$event_panel->setHeaderText(pht('Events'));
$event_panel->appendChild($event_view);
$object_box = id(new PHUIObjectBoxView())
->setHeader($header)
->addPropertyList($properties);
return $this->buildApplicationPage(
array(
$crumbs,
$object_box,
$event_panel,
),
array(
'title' => pht('Daemon Log'),
));
}
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));
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/applications/daemon/controller/PhabricatorWorkerTaskDetailController.php b/src/applications/daemon/controller/PhabricatorWorkerTaskDetailController.php
index 66925ffd36..a0c8608935 100644
--- a/src/applications/daemon/controller/PhabricatorWorkerTaskDetailController.php
+++ b/src/applications/daemon/controller/PhabricatorWorkerTaskDetailController.php
@@ -1,224 +1,218 @@
<?php
final class PhabricatorWorkerTaskDetailController
extends PhabricatorDaemonController {
- private $id;
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $user = $request->getUser();
-
- $task = id(new PhabricatorWorkerActiveTask())->load($this->id);
+ $task = id(new PhabricatorWorkerActiveTask())->load($id);
if (!$task) {
$tasks = id(new PhabricatorWorkerArchiveTaskQuery())
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->execute();
$task = reset($tasks);
}
if (!$task) {
$title = pht('Task Does Not Exist');
$error_view = new PHUIInfoView();
$error_view->setTitle(pht('No Such Task'));
$error_view->appendChild(phutil_tag(
'p',
array(),
pht('This task may have recently been garbage collected.')));
$error_view->setSeverity(PHUIInfoView::SEVERITY_NODATA);
$content = $error_view;
} else {
$title = pht('Task %d', $task->getID());
$header = id(new PHUIHeaderView())
->setHeader(pht('Task %d (%s)',
$task->getID(),
$task->getTaskClass()));
$properties = $this->buildPropertyListView($task);
$object_box = id(new PHUIObjectBoxView())
->setHeader($header)
->addPropertyList($properties);
$retry_head = id(new PHUIHeaderView())
->setHeader(pht('Retries'));
$retry_info = $this->buildRetryListView($task);
$retry_box = id(new PHUIObjectBoxView())
->setHeader($retry_head)
->addPropertyList($retry_info);
$content = array(
$object_box,
$retry_box,
);
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title);
return $this->buildApplicationPage(
array(
$crumbs,
$content,
),
array(
'title' => $title,
));
}
private function buildPropertyListView(
PhabricatorWorkerTask $task) {
$viewer = $this->getRequest()->getUser();
$view = new PHUIPropertyListView();
if ($task->isArchived()) {
switch ($task->getResult()) {
case PhabricatorWorkerArchiveTask::RESULT_SUCCESS:
$status = pht('Complete');
break;
case PhabricatorWorkerArchiveTask::RESULT_FAILURE:
$status = pht('Failed');
break;
case PhabricatorWorkerArchiveTask::RESULT_CANCELLED:
$status = pht('Cancelled');
break;
default:
throw new Exception(pht('Unknown task status!'));
}
} else {
$status = pht('Queued');
}
$view->addProperty(
pht('Task Status'),
$status);
$view->addProperty(
pht('Task Class'),
$task->getTaskClass());
if ($task->getLeaseExpires()) {
if ($task->getLeaseExpires() > time()) {
$lease_status = pht('Leased');
} else {
$lease_status = pht('Lease Expired');
}
} else {
$lease_status = phutil_tag('em', array(), pht('Not Leased'));
}
$view->addProperty(
pht('Lease Status'),
$lease_status);
$view->addProperty(
pht('Lease Owner'),
$task->getLeaseOwner()
? $task->getLeaseOwner()
: phutil_tag('em', array(), pht('None')));
if ($task->getLeaseExpires() && $task->getLeaseOwner()) {
$expires = ($task->getLeaseExpires() - time());
$expires = phutil_format_relative_time_detailed($expires);
} else {
$expires = phutil_tag('em', array(), pht('None'));
}
$view->addProperty(
pht('Lease Expires'),
$expires);
if ($task->isArchived()) {
$duration = pht('%s us', new PhutilNumber($task->getDuration()));
} else {
$duration = phutil_tag('em', array(), pht('Not Completed'));
}
$view->addProperty(
pht('Duration'),
$duration);
$data = id(new PhabricatorWorkerTaskData())->load($task->getDataID());
$task->setData($data->getData());
$worker = $task->getWorkerInstance();
$data = $worker->renderForDisplay($viewer);
$view->addProperty(
pht('Data'),
$data);
return $view;
}
private function buildRetryListView(PhabricatorWorkerTask $task) {
$view = new PHUIPropertyListView();
$data = id(new PhabricatorWorkerTaskData())->load($task->getDataID());
$task->setData($data->getData());
$worker = $task->getWorkerInstance();
$view->addProperty(
pht('Failure Count'),
$task->getFailureCount());
$retry_count = $worker->getMaximumRetryCount();
if ($retry_count === null) {
$max_retries = phutil_tag('em', array(), pht('Retries Forever'));
$retry_count = INF;
} else {
$max_retries = $retry_count;
}
$view->addProperty(
pht('Maximum Retries'),
$max_retries);
$projection = clone $task;
$projection->makeEphemeral();
$next = array();
for ($ii = $task->getFailureCount(); $ii < $retry_count; $ii++) {
$projection->setFailureCount($ii);
$next[] = $worker->getWaitBeforeRetry($projection);
if (count($next) > 10) {
break;
}
}
if ($next) {
$cumulative = 0;
foreach ($next as $key => $duration) {
if ($duration === null) {
$duration = 60;
}
$cumulative += $duration;
$next[$key] = phutil_format_relative_time($cumulative);
}
if ($ii != $retry_count) {
$next[] = '...';
}
$retries_in = implode(', ', $next);
} else {
$retries_in = pht('No More Retries');
}
$view->addProperty(
pht('Retries After'),
$retries_in);
return $view;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 17:33 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1127007
Default Alt Text
(16 KB)

Event Timeline