2011-03-10 22:48:29 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class PhabricatorDaemonConsoleController
|
|
|
|
extends PhabricatorDaemonController {
|
2011-03-10 22:48:29 +01:00
|
|
|
|
|
|
|
public function processRequest() {
|
Use phabricator_ time functions in more places
Summary:
Replace some more date() calls with locale-aware calls.
Also, at least on my system, the DateTimeZone / DateTime stuff didn't actually
work and always rendered in UTC. Fixed that.
Test Plan:
Viewed daemon console, differential revisions, files, and maniphest timestamps
in multiple timezones.
Reviewed By: toulouse
Reviewers: toulouse, fratrik, jungejason, aran, tuomaspelkonen
CC: aran, toulouse
Differential Revision: 530
2011-06-26 18:22:52 +02:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
Improve Daemon console UI
Summary:
Makes various fixes to the Daemon console UI:
- Removes timeline, timeline cursors, and timeline-related controllers. This abstraction is all but dead and just waiting on an eventual cleanup effort with Facebook (see T2003). There's no need to inspect or debug it anymore.
- Instead of showing the 15 most recently launched non-exited daemons, show all the running daemons. With the old rule, "dead" daemons tended to build up at the bottom of the list -- e.g., secure.phabricator.com shows the 7 active daemons, then 8 dead daemons from as far back as Aug 2012. Showing running daemons is far more useful.
- Simplify the two "Running Daemons" and "All Daemons" subviews into one "All Daemons" subview. The main console now has "running daemons", effectively.
- Create a "Recently completed tasks" view, which shows how many tasks of each task class have completed in the last 15 minutes and how long they took on average. Understanding how quickly tasks are completing is one of the most common uses of the daemon console, and it's currently almost useless for that. Now that we archive tasks, we can show this information in an easily digestable form.
- Partially modernize all of the remaining views.
Test Plan: Looked at daemon console.
Reviewers: btrahan, chad, vrana
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2372, T2003
Differential Revision: https://secure.phabricator.com/D4573
2013-01-22 21:14:33 +01:00
|
|
|
$completed = id(new PhabricatorWorkerArchiveTask())->loadAllWhere(
|
|
|
|
'dateModified > %d',
|
|
|
|
time() - (60 * 15));
|
|
|
|
|
|
|
|
$completed_info = array();
|
|
|
|
foreach ($completed as $completed_task) {
|
|
|
|
$class = $completed_task->getTaskClass();
|
|
|
|
if (empty($completed_info[$class])) {
|
|
|
|
$completed_info[$class] = array(
|
|
|
|
'n' => 0,
|
|
|
|
'duration' => 0,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$completed_info[$class]['n']++;
|
|
|
|
$duration = $completed_task->getDuration();
|
|
|
|
$completed_info[$class]['duration'] += $duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
$completed_info = isort($completed_info, 'n');
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($completed_info as $class => $info) {
|
|
|
|
$rows[] = array(
|
2013-02-13 23:50:15 +01:00
|
|
|
$class,
|
Improve Daemon console UI
Summary:
Makes various fixes to the Daemon console UI:
- Removes timeline, timeline cursors, and timeline-related controllers. This abstraction is all but dead and just waiting on an eventual cleanup effort with Facebook (see T2003). There's no need to inspect or debug it anymore.
- Instead of showing the 15 most recently launched non-exited daemons, show all the running daemons. With the old rule, "dead" daemons tended to build up at the bottom of the list -- e.g., secure.phabricator.com shows the 7 active daemons, then 8 dead daemons from as far back as Aug 2012. Showing running daemons is far more useful.
- Simplify the two "Running Daemons" and "All Daemons" subviews into one "All Daemons" subview. The main console now has "running daemons", effectively.
- Create a "Recently completed tasks" view, which shows how many tasks of each task class have completed in the last 15 minutes and how long they took on average. Understanding how quickly tasks are completing is one of the most common uses of the daemon console, and it's currently almost useless for that. Now that we archive tasks, we can show this information in an easily digestable form.
- Partially modernize all of the remaining views.
Test Plan: Looked at daemon console.
Reviewers: btrahan, chad, vrana
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2372, T2003
Differential Revision: https://secure.phabricator.com/D4573
2013-01-22 21:14:33 +01:00
|
|
|
number_format($info['n']),
|
|
|
|
number_format((int)($info['duration'] / $info['n'])).' us',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$completed_table = new AphrontTableView($rows);
|
|
|
|
$completed_table->setNoDataString(
|
|
|
|
pht('No tasks have completed in the last 15 minutes.'));
|
|
|
|
$completed_table->setHeaders(
|
|
|
|
array(
|
|
|
|
pht('Class'),
|
|
|
|
pht('Count'),
|
|
|
|
pht('Avg'),
|
|
|
|
));
|
|
|
|
$completed_table->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'wide',
|
|
|
|
'n',
|
|
|
|
'n',
|
|
|
|
));
|
|
|
|
|
|
|
|
$completed_panel = new AphrontPanelView();
|
|
|
|
$completed_panel->setHeader(pht('Recently Completed Tasks (15m)'));
|
|
|
|
$completed_panel->appendChild($completed_table);
|
|
|
|
$completed_panel->setNoBackground();
|
|
|
|
|
|
|
|
$logs = id(new PhabricatorDaemonLog())->loadAllWhere(
|
|
|
|
'`status` = %s ORDER BY id DESC',
|
|
|
|
'run');
|
|
|
|
|
2011-05-03 02:05:22 +02:00
|
|
|
$daemon_table = new PhabricatorDaemonLogListView();
|
Use phabricator_ time functions in more places
Summary:
Replace some more date() calls with locale-aware calls.
Also, at least on my system, the DateTimeZone / DateTime stuff didn't actually
work and always rendered in UTC. Fixed that.
Test Plan:
Viewed daemon console, differential revisions, files, and maniphest timestamps
in multiple timezones.
Reviewed By: toulouse
Reviewers: toulouse, fratrik, jungejason, aran, tuomaspelkonen
CC: aran, toulouse
Differential Revision: 530
2011-06-26 18:22:52 +02:00
|
|
|
$daemon_table->setUser($user);
|
2011-05-03 02:05:22 +02:00
|
|
|
$daemon_table->setDaemonLogs($logs);
|
2011-03-15 21:38:14 +01:00
|
|
|
|
|
|
|
$daemon_panel = new AphrontPanelView();
|
2013-02-27 04:51:36 +01:00
|
|
|
$daemon_panel->setHeader(pht('Active Daemons'));
|
2011-03-15 21:38:14 +01:00
|
|
|
$daemon_panel->appendChild($daemon_table);
|
Improve Daemon console UI
Summary:
Makes various fixes to the Daemon console UI:
- Removes timeline, timeline cursors, and timeline-related controllers. This abstraction is all but dead and just waiting on an eventual cleanup effort with Facebook (see T2003). There's no need to inspect or debug it anymore.
- Instead of showing the 15 most recently launched non-exited daemons, show all the running daemons. With the old rule, "dead" daemons tended to build up at the bottom of the list -- e.g., secure.phabricator.com shows the 7 active daemons, then 8 dead daemons from as far back as Aug 2012. Showing running daemons is far more useful.
- Simplify the two "Running Daemons" and "All Daemons" subviews into one "All Daemons" subview. The main console now has "running daemons", effectively.
- Create a "Recently completed tasks" view, which shows how many tasks of each task class have completed in the last 15 minutes and how long they took on average. Understanding how quickly tasks are completing is one of the most common uses of the daemon console, and it's currently almost useless for that. Now that we archive tasks, we can show this information in an easily digestable form.
- Partially modernize all of the remaining views.
Test Plan: Looked at daemon console.
Reviewers: btrahan, chad, vrana
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2372, T2003
Differential Revision: https://secure.phabricator.com/D4573
2013-01-22 21:14:33 +01:00
|
|
|
$daemon_panel->setNoBackground();
|
2011-03-15 21:38:14 +01:00
|
|
|
|
2012-10-31 23:22:16 +01:00
|
|
|
$tasks = id(new PhabricatorWorkerActiveTask())->loadAllWhere(
|
2011-03-11 18:34:22 +01:00
|
|
|
'leaseOwner IS NOT NULL');
|
2011-03-10 22:48:29 +01:00
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($tasks as $task) {
|
|
|
|
$rows[] = array(
|
|
|
|
$task->getID(),
|
|
|
|
$task->getTaskClass(),
|
|
|
|
$task->getLeaseOwner(),
|
2011-03-11 18:34:22 +01:00
|
|
|
$task->getLeaseExpires() - time(),
|
2011-03-10 22:48:29 +01:00
|
|
|
$task->getFailureCount(),
|
2013-01-18 03:57:09 +01:00
|
|
|
phutil_tag(
|
2011-03-27 07:55:18 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/daemon/task/'.$task->getID().'/',
|
|
|
|
'class' => 'button small grey',
|
|
|
|
),
|
2013-02-27 04:51:36 +01:00
|
|
|
pht('View Task')),
|
2011-03-10 22:48:29 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-03-11 18:34:22 +01:00
|
|
|
$leased_table = new AphrontTableView($rows);
|
|
|
|
$leased_table->setHeaders(
|
2011-03-10 22:48:29 +01:00
|
|
|
array(
|
2013-02-27 04:51:36 +01:00
|
|
|
pht('ID'),
|
|
|
|
pht('Class'),
|
|
|
|
pht('Owner'),
|
|
|
|
pht('Expires'),
|
|
|
|
pht('Failures'),
|
2011-03-27 07:55:18 +02:00
|
|
|
'',
|
2011-03-11 18:34:22 +01:00
|
|
|
));
|
|
|
|
$leased_table->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'n',
|
|
|
|
'wide',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'n',
|
2011-03-27 07:55:18 +02:00
|
|
|
'action',
|
2011-03-11 18:34:22 +01:00
|
|
|
));
|
2013-02-27 04:51:36 +01:00
|
|
|
$leased_table->setNoDataString(pht('No tasks are leased by workers.'));
|
2011-03-11 18:34:22 +01:00
|
|
|
|
|
|
|
$leased_panel = new AphrontPanelView();
|
|
|
|
$leased_panel->setHeader('Leased Tasks');
|
|
|
|
$leased_panel->appendChild($leased_table);
|
Improve Daemon console UI
Summary:
Makes various fixes to the Daemon console UI:
- Removes timeline, timeline cursors, and timeline-related controllers. This abstraction is all but dead and just waiting on an eventual cleanup effort with Facebook (see T2003). There's no need to inspect or debug it anymore.
- Instead of showing the 15 most recently launched non-exited daemons, show all the running daemons. With the old rule, "dead" daemons tended to build up at the bottom of the list -- e.g., secure.phabricator.com shows the 7 active daemons, then 8 dead daemons from as far back as Aug 2012. Showing running daemons is far more useful.
- Simplify the two "Running Daemons" and "All Daemons" subviews into one "All Daemons" subview. The main console now has "running daemons", effectively.
- Create a "Recently completed tasks" view, which shows how many tasks of each task class have completed in the last 15 minutes and how long they took on average. Understanding how quickly tasks are completing is one of the most common uses of the daemon console, and it's currently almost useless for that. Now that we archive tasks, we can show this information in an easily digestable form.
- Partially modernize all of the remaining views.
Test Plan: Looked at daemon console.
Reviewers: btrahan, chad, vrana
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2372, T2003
Differential Revision: https://secure.phabricator.com/D4573
2013-01-22 21:14:33 +01:00
|
|
|
$leased_panel->setNoBackground();
|
2011-03-11 18:34:22 +01:00
|
|
|
|
2012-10-31 23:22:16 +01:00
|
|
|
$task_table = new PhabricatorWorkerActiveTask();
|
2011-03-11 18:34:22 +01:00
|
|
|
$queued = queryfx_all(
|
|
|
|
$task_table->establishConnection('r'),
|
|
|
|
'SELECT taskClass, count(*) N FROM %T GROUP BY taskClass
|
|
|
|
ORDER BY N DESC',
|
|
|
|
$task_table->getTableName());
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($queued as $row) {
|
|
|
|
$rows[] = array(
|
2013-02-13 23:50:15 +01:00
|
|
|
$row['taskClass'],
|
2011-03-11 18:34:22 +01:00
|
|
|
number_format($row['N']),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$queued_table = new AphrontTableView($rows);
|
|
|
|
$queued_table->setHeaders(
|
|
|
|
array(
|
2013-02-27 04:51:36 +01:00
|
|
|
pht('Class'),
|
|
|
|
pht('Count'),
|
2011-03-10 22:48:29 +01:00
|
|
|
));
|
2011-03-11 18:34:22 +01:00
|
|
|
$queued_table->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'wide',
|
|
|
|
'n',
|
|
|
|
));
|
2013-02-27 04:51:36 +01:00
|
|
|
$queued_table->setNoDataString(pht('Task queue is empty.'));
|
2011-03-11 18:34:22 +01:00
|
|
|
|
|
|
|
$queued_panel = new AphrontPanelView();
|
2013-02-27 04:51:36 +01:00
|
|
|
$queued_panel->setHeader(pht('Queued Tasks'));
|
2011-03-11 18:34:22 +01:00
|
|
|
$queued_panel->appendChild($queued_table);
|
Improve Daemon console UI
Summary:
Makes various fixes to the Daemon console UI:
- Removes timeline, timeline cursors, and timeline-related controllers. This abstraction is all but dead and just waiting on an eventual cleanup effort with Facebook (see T2003). There's no need to inspect or debug it anymore.
- Instead of showing the 15 most recently launched non-exited daemons, show all the running daemons. With the old rule, "dead" daemons tended to build up at the bottom of the list -- e.g., secure.phabricator.com shows the 7 active daemons, then 8 dead daemons from as far back as Aug 2012. Showing running daemons is far more useful.
- Simplify the two "Running Daemons" and "All Daemons" subviews into one "All Daemons" subview. The main console now has "running daemons", effectively.
- Create a "Recently completed tasks" view, which shows how many tasks of each task class have completed in the last 15 minutes and how long they took on average. Understanding how quickly tasks are completing is one of the most common uses of the daemon console, and it's currently almost useless for that. Now that we archive tasks, we can show this information in an easily digestable form.
- Partially modernize all of the remaining views.
Test Plan: Looked at daemon console.
Reviewers: btrahan, chad, vrana
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2372, T2003
Differential Revision: https://secure.phabricator.com/D4573
2013-01-22 21:14:33 +01:00
|
|
|
$queued_panel->setNoBackground();
|
2011-03-10 22:48:29 +01:00
|
|
|
|
2012-08-14 00:27:45 +02:00
|
|
|
$nav = $this->buildSideNavView();
|
Improve Daemon console UI
Summary:
Makes various fixes to the Daemon console UI:
- Removes timeline, timeline cursors, and timeline-related controllers. This abstraction is all but dead and just waiting on an eventual cleanup effort with Facebook (see T2003). There's no need to inspect or debug it anymore.
- Instead of showing the 15 most recently launched non-exited daemons, show all the running daemons. With the old rule, "dead" daemons tended to build up at the bottom of the list -- e.g., secure.phabricator.com shows the 7 active daemons, then 8 dead daemons from as far back as Aug 2012. Showing running daemons is far more useful.
- Simplify the two "Running Daemons" and "All Daemons" subviews into one "All Daemons" subview. The main console now has "running daemons", effectively.
- Create a "Recently completed tasks" view, which shows how many tasks of each task class have completed in the last 15 minutes and how long they took on average. Understanding how quickly tasks are completing is one of the most common uses of the daemon console, and it's currently almost useless for that. Now that we archive tasks, we can show this information in an easily digestable form.
- Partially modernize all of the remaining views.
Test Plan: Looked at daemon console.
Reviewers: btrahan, chad, vrana
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2372, T2003
Differential Revision: https://secure.phabricator.com/D4573
2013-01-22 21:14:33 +01:00
|
|
|
$nav->selectFilter('/');
|
2012-08-14 00:27:45 +02:00
|
|
|
$nav->appendChild(
|
2011-03-11 18:34:22 +01:00
|
|
|
array(
|
Improve Daemon console UI
Summary:
Makes various fixes to the Daemon console UI:
- Removes timeline, timeline cursors, and timeline-related controllers. This abstraction is all but dead and just waiting on an eventual cleanup effort with Facebook (see T2003). There's no need to inspect or debug it anymore.
- Instead of showing the 15 most recently launched non-exited daemons, show all the running daemons. With the old rule, "dead" daemons tended to build up at the bottom of the list -- e.g., secure.phabricator.com shows the 7 active daemons, then 8 dead daemons from as far back as Aug 2012. Showing running daemons is far more useful.
- Simplify the two "Running Daemons" and "All Daemons" subviews into one "All Daemons" subview. The main console now has "running daemons", effectively.
- Create a "Recently completed tasks" view, which shows how many tasks of each task class have completed in the last 15 minutes and how long they took on average. Understanding how quickly tasks are completing is one of the most common uses of the daemon console, and it's currently almost useless for that. Now that we archive tasks, we can show this information in an easily digestable form.
- Partially modernize all of the remaining views.
Test Plan: Looked at daemon console.
Reviewers: btrahan, chad, vrana
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2372, T2003
Differential Revision: https://secure.phabricator.com/D4573
2013-01-22 21:14:33 +01:00
|
|
|
$completed_panel,
|
2011-03-15 21:38:14 +01:00
|
|
|
$daemon_panel,
|
2012-04-13 11:17:34 +02:00
|
|
|
$queued_panel,
|
|
|
|
$leased_panel,
|
2012-08-14 00:27:45 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
$nav,
|
2011-03-10 22:48:29 +01:00
|
|
|
array(
|
2013-02-27 04:51:36 +01:00
|
|
|
'title' => pht('Console'),
|
2011-03-10 22:48:29 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|