2011-03-10 22:48:29 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2012-02-28 02:11:25 +01:00
|
|
|
* Copyright 2012 Facebook, Inc.
|
2011-03-10 22:48:29 +01:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class PhabricatorDaemonConsoleController
|
|
|
|
extends PhabricatorDaemonController {
|
2011-03-10 22:48:29 +01:00
|
|
|
|
|
|
|
public function processRequest() {
|
2011-03-15 21:38:14 +01:00
|
|
|
$logs = id(new PhabricatorDaemonLog())->loadAllWhere(
|
|
|
|
'1 = 1 ORDER BY id DESC LIMIT 15');
|
|
|
|
|
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();
|
|
|
|
|
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();
|
2011-05-03 02:05:22 +02:00
|
|
|
$daemon_panel->setHeader(
|
|
|
|
'Recently Launched Daemons'.
|
|
|
|
' · '.
|
|
|
|
phutil_render_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/daemon/log/',
|
|
|
|
),
|
|
|
|
'View All Daemons').
|
|
|
|
' · '.
|
|
|
|
phutil_render_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/daemon/log/combined/',
|
|
|
|
),
|
|
|
|
'View Combined Log'));
|
2011-03-15 21:38:14 +01:00
|
|
|
$daemon_panel->appendChild($daemon_table);
|
|
|
|
|
2011-03-11 18:34:22 +01:00
|
|
|
$tasks = id(new PhabricatorWorkerTask())->loadAllWhere(
|
|
|
|
'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(),
|
2011-03-27 07:55:18 +02:00
|
|
|
phutil_render_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/daemon/task/'.$task->getID().'/',
|
|
|
|
'class' => 'button small grey',
|
|
|
|
),
|
|
|
|
'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(
|
|
|
|
'ID',
|
|
|
|
'Class',
|
|
|
|
'Owner',
|
2012-02-28 02:11:25 +01:00
|
|
|
'Expires',
|
2011-03-11 18:34:22 +01:00
|
|
|
'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
|
|
|
));
|
|
|
|
$leased_table->setNoDataString('No tasks are leased by workers.');
|
|
|
|
|
|
|
|
$leased_panel = new AphrontPanelView();
|
|
|
|
$leased_panel->setHeader('Leased Tasks');
|
|
|
|
$leased_panel->appendChild($leased_table);
|
|
|
|
|
|
|
|
$task_table = new PhabricatorWorkerTask();
|
|
|
|
$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(
|
|
|
|
phutil_escape_html($row['taskClass']),
|
|
|
|
number_format($row['N']),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$queued_table = new AphrontTableView($rows);
|
|
|
|
$queued_table->setHeaders(
|
|
|
|
array(
|
|
|
|
'Class',
|
2011-03-10 22:48:29 +01:00
|
|
|
'Count',
|
|
|
|
));
|
2011-03-11 18:34:22 +01:00
|
|
|
$queued_table->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'wide',
|
|
|
|
'n',
|
|
|
|
));
|
|
|
|
$queued_table->setNoDataString('Task queue is empty.');
|
|
|
|
|
|
|
|
$queued_panel = new AphrontPanelView();
|
|
|
|
$queued_panel->setHeader('Queued Tasks');
|
|
|
|
$queued_panel->appendChild($queued_table);
|
|
|
|
|
|
|
|
$cursors = id(new PhabricatorTimelineCursor())
|
|
|
|
->loadAll();
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($cursors as $cursor) {
|
|
|
|
$rows[] = array(
|
|
|
|
phutil_escape_html($cursor->getName()),
|
|
|
|
number_format($cursor->getPosition()),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$cursor_table = new AphrontTableView($rows);
|
|
|
|
$cursor_table->setHeaders(
|
|
|
|
array(
|
|
|
|
'Name',
|
|
|
|
'Position',
|
|
|
|
));
|
|
|
|
$cursor_table->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'wide',
|
|
|
|
'n',
|
|
|
|
));
|
|
|
|
$cursor_table->setNoDataString('No timeline cursors exist.');
|
2011-03-10 22:48:29 +01:00
|
|
|
|
2011-03-11 18:34:22 +01:00
|
|
|
$cursor_panel = new AphrontPanelView();
|
|
|
|
$cursor_panel->setHeader('Timeline Cursors');
|
|
|
|
$cursor_panel->appendChild($cursor_table);
|
2011-03-10 22:48:29 +01:00
|
|
|
|
|
|
|
return $this->buildStandardPageResponse(
|
2011-03-11 18:34:22 +01:00
|
|
|
array(
|
2011-03-15 21:38:14 +01:00
|
|
|
$daemon_panel,
|
2011-03-11 18:34:22 +01:00
|
|
|
$leased_panel,
|
|
|
|
$queued_panel,
|
|
|
|
$cursor_panel,
|
|
|
|
),
|
2011-03-10 22:48:29 +01:00
|
|
|
array(
|
|
|
|
'title' => 'Console',
|
|
|
|
'tab' => 'console',
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|