1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 21:40:55 +01:00

Improve daemon console.

This commit is contained in:
epriestley 2011-03-26 22:55:18 -07:00
parent 1844a6f728
commit c22124db85
6 changed files with 159 additions and 9 deletions

View file

@ -386,6 +386,7 @@ phutil_register_library_map(array(
'PhabricatorWorkerDAO' => 'infrastructure/daemon/workers/storage/base', 'PhabricatorWorkerDAO' => 'infrastructure/daemon/workers/storage/base',
'PhabricatorWorkerTask' => 'infrastructure/daemon/workers/storage/task', 'PhabricatorWorkerTask' => 'infrastructure/daemon/workers/storage/task',
'PhabricatorWorkerTaskData' => 'infrastructure/daemon/workers/storage/taskdata', 'PhabricatorWorkerTaskData' => 'infrastructure/daemon/workers/storage/taskdata',
'PhabricatorWorkerTaskDetailController' => 'applications/daemon/controller/workertaskdetail',
'PhabricatorXHProfController' => 'applications/xhprof/controller/base', 'PhabricatorXHProfController' => 'applications/xhprof/controller/base',
'PhabricatorXHProfProfileController' => 'applications/xhprof/controller/profile', 'PhabricatorXHProfProfileController' => 'applications/xhprof/controller/profile',
'PhabricatorXHProfProfileSymbolView' => 'applications/xhprof/view/symbol', 'PhabricatorXHProfProfileSymbolView' => 'applications/xhprof/view/symbol',
@ -706,6 +707,7 @@ phutil_register_library_map(array(
'PhabricatorWorkerDAO' => 'PhabricatorLiskDAO', 'PhabricatorWorkerDAO' => 'PhabricatorLiskDAO',
'PhabricatorWorkerTask' => 'PhabricatorWorkerDAO', 'PhabricatorWorkerTask' => 'PhabricatorWorkerDAO',
'PhabricatorWorkerTaskData' => 'PhabricatorWorkerDAO', 'PhabricatorWorkerTaskData' => 'PhabricatorWorkerDAO',
'PhabricatorWorkerTaskDetailController' => 'PhabricatorDaemonController',
'PhabricatorXHProfController' => 'PhabricatorController', 'PhabricatorXHProfController' => 'PhabricatorController',
'PhabricatorXHProfProfileController' => 'PhabricatorXHProfController', 'PhabricatorXHProfProfileController' => 'PhabricatorXHProfController',
'PhabricatorXHProfProfileSymbolView' => 'AphrontView', 'PhabricatorXHProfProfileSymbolView' => 'AphrontView',

View file

@ -209,6 +209,7 @@ class AphrontDefaultApplicationConfiguration
), ),
'/daemon/' => array( '/daemon/' => array(
'task/(?P<id>\d+)/$' => 'PhabricatorWorkerTaskDetailController',
'log/' => array( 'log/' => array(
'(?P<id>\d+)/$' => 'PhabricatorDaemonLogViewController', '(?P<id>\d+)/$' => 'PhabricatorDaemonLogViewController',
), ),

View file

@ -26,15 +26,10 @@ class PhabricatorDaemonConsoleController extends PhabricatorDaemonController {
foreach ($logs as $log) { foreach ($logs as $log) {
$epoch = $log->getDateCreated(); $epoch = $log->getDateCreated();
$argv = $log->getArgv();
$argv = array_map('phutil_escape_html', $argv);
$argv = implode('<br />', $argv);
$rows[] = array( $rows[] = array(
phutil_escape_html($log->getDaemon()), phutil_escape_html($log->getDaemon()),
phutil_escape_html($log->getHost()), phutil_escape_html($log->getHost()),
$log->getPID(), $log->getPID(),
$argv,
date('M j, Y', $epoch), date('M j, Y', $epoch),
date('g:i A', $epoch), date('g:i A', $epoch),
phutil_render_tag( phutil_render_tag(
@ -53,18 +48,16 @@ class PhabricatorDaemonConsoleController extends PhabricatorDaemonController {
'Daemon', 'Daemon',
'Host', 'Host',
'PID', 'PID',
'Argv',
'Date', 'Date',
'Time', 'Time',
'View', 'View',
)); ));
$daemon_table->setColumnClasses( $daemon_table->setColumnClasses(
array( array(
'',
'',
'',
'wide wrap', 'wide wrap',
'', '',
'',
'',
'right', 'right',
'action', 'action',
)); ));
@ -84,6 +77,13 @@ class PhabricatorDaemonConsoleController extends PhabricatorDaemonController {
$task->getLeaseOwner(), $task->getLeaseOwner(),
$task->getLeaseExpires() - time(), $task->getLeaseExpires() - time(),
$task->getFailureCount(), $task->getFailureCount(),
phutil_render_tag(
'a',
array(
'href' => '/daemon/task/'.$task->getID().'/',
'class' => 'button small grey',
),
'View Task'),
); );
} }
@ -95,6 +95,7 @@ class PhabricatorDaemonConsoleController extends PhabricatorDaemonController {
'Owner', 'Owner',
'Expries', 'Expries',
'Failures', 'Failures',
'',
)); ));
$leased_table->setColumnClasses( $leased_table->setColumnClasses(
array( array(
@ -103,6 +104,7 @@ class PhabricatorDaemonConsoleController extends PhabricatorDaemonController {
'', '',
'', '',
'n', 'n',
'action',
)); ));
$leased_table->setNoDataString('No tasks are leased by workers.'); $leased_table->setNoDataString('No tasks are leased by workers.');

View file

@ -25,6 +25,8 @@ class PhabricatorDaemonLogViewController extends PhabricatorDaemonController {
} }
public function processRequest() { public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$log = id(new PhabricatorDaemonLog())->load($this->id); $log = id(new PhabricatorDaemonLog())->load($this->id);
if (!$log) { if (!$log) {
@ -37,6 +39,38 @@ class PhabricatorDaemonLogViewController extends PhabricatorDaemonController {
$content = array(); $content = array();
$argv = $log->getArgv();
$argv = implode("\n", $argv);
$form = id(new AphrontFormView())
->setUser($user)
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Daemon')
->setValue($log->getDaemon()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Host')
->setValue($log->getHost()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('PID')
->setValue($log->getPID()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Started')
->setValue(date('F jS, Y g:i:s A', $log->getDateCreated())))
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Argv')
->setValue($argv));
$panel = new AphrontPanelView();
$panel->setHeader('Daemon Details');
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->appendChild($form);
$content[] = $panel;
$rows = array(); $rows = array();
foreach ($events as $event) { foreach ($events as $event) {

View file

@ -0,0 +1,95 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* 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.
*/
class PhabricatorWorkerTaskDetailController
extends PhabricatorDaemonController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$task = id(new PhabricatorWorkerTask())->load($this->id);
if (!$task) {
$error_view = new AphrontErrorView();
$error_view->setTitle('No Such Task');
$error_view->appendChild(
'<p>This task may have recently completed.</p>');
$error_view->setSeverity(AphrontErrorView::SEVERITY_WARNING);
return $this->buildStandardPageResponse(
$error_view,
array(
'title' => 'Task Does Not Exist',
));
}
$data = id(new PhabricatorWorkerTaskData())->loadOneWhere(
'taskID = %d',
$task->getID());
if ($data) {
$data = json_encode($data->getData());
}
$form = id(new AphrontFormView())
->setUser($user)
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('ID')
->setValue($task->getID()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Type')
->setValue($task->getTaskClass()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Lease Owner')
->setValue($task->getLeaseOwner()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Lease Expires')
->setValue($task->getLeaseExpires() - time()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Failure Count')
->setValue($task->getFailureCount()))
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Data')
->setValue($data))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton('/daemon/'));
$panel = new AphrontPanelView();
$panel->setHeader('Task Detail');
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->appendChild($form);
return $this->buildStandardPageResponse(
$panel,
array(
'title' => 'Task',
));
}
}

View file

@ -0,0 +1,16 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/daemon/controller/base');
phutil_require_module('phabricator', 'infrastructure/daemon/workers/storage/task');
phutil_require_module('phabricator', 'view/form/error');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorWorkerTaskDetailController.php');