mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Improve daemon console.
This commit is contained in:
parent
1844a6f728
commit
c22124db85
6 changed files with 159 additions and 9 deletions
|
@ -386,6 +386,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorWorkerDAO' => 'infrastructure/daemon/workers/storage/base',
|
||||
'PhabricatorWorkerTask' => 'infrastructure/daemon/workers/storage/task',
|
||||
'PhabricatorWorkerTaskData' => 'infrastructure/daemon/workers/storage/taskdata',
|
||||
'PhabricatorWorkerTaskDetailController' => 'applications/daemon/controller/workertaskdetail',
|
||||
'PhabricatorXHProfController' => 'applications/xhprof/controller/base',
|
||||
'PhabricatorXHProfProfileController' => 'applications/xhprof/controller/profile',
|
||||
'PhabricatorXHProfProfileSymbolView' => 'applications/xhprof/view/symbol',
|
||||
|
@ -706,6 +707,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorWorkerDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorWorkerTask' => 'PhabricatorWorkerDAO',
|
||||
'PhabricatorWorkerTaskData' => 'PhabricatorWorkerDAO',
|
||||
'PhabricatorWorkerTaskDetailController' => 'PhabricatorDaemonController',
|
||||
'PhabricatorXHProfController' => 'PhabricatorController',
|
||||
'PhabricatorXHProfProfileController' => 'PhabricatorXHProfController',
|
||||
'PhabricatorXHProfProfileSymbolView' => 'AphrontView',
|
||||
|
|
|
@ -209,6 +209,7 @@ class AphrontDefaultApplicationConfiguration
|
|||
),
|
||||
|
||||
'/daemon/' => array(
|
||||
'task/(?P<id>\d+)/$' => 'PhabricatorWorkerTaskDetailController',
|
||||
'log/' => array(
|
||||
'(?P<id>\d+)/$' => 'PhabricatorDaemonLogViewController',
|
||||
),
|
||||
|
|
|
@ -26,15 +26,10 @@ class PhabricatorDaemonConsoleController extends PhabricatorDaemonController {
|
|||
foreach ($logs as $log) {
|
||||
$epoch = $log->getDateCreated();
|
||||
|
||||
$argv = $log->getArgv();
|
||||
$argv = array_map('phutil_escape_html', $argv);
|
||||
$argv = implode('<br />', $argv);
|
||||
|
||||
$rows[] = array(
|
||||
phutil_escape_html($log->getDaemon()),
|
||||
phutil_escape_html($log->getHost()),
|
||||
$log->getPID(),
|
||||
$argv,
|
||||
date('M j, Y', $epoch),
|
||||
date('g:i A', $epoch),
|
||||
phutil_render_tag(
|
||||
|
@ -53,18 +48,16 @@ class PhabricatorDaemonConsoleController extends PhabricatorDaemonController {
|
|||
'Daemon',
|
||||
'Host',
|
||||
'PID',
|
||||
'Argv',
|
||||
'Date',
|
||||
'Time',
|
||||
'View',
|
||||
));
|
||||
$daemon_table->setColumnClasses(
|
||||
array(
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'wide wrap',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'right',
|
||||
'action',
|
||||
));
|
||||
|
@ -84,6 +77,13 @@ class PhabricatorDaemonConsoleController extends PhabricatorDaemonController {
|
|||
$task->getLeaseOwner(),
|
||||
$task->getLeaseExpires() - time(),
|
||||
$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',
|
||||
'Expries',
|
||||
'Failures',
|
||||
'',
|
||||
));
|
||||
$leased_table->setColumnClasses(
|
||||
array(
|
||||
|
@ -103,6 +104,7 @@ class PhabricatorDaemonConsoleController extends PhabricatorDaemonController {
|
|||
'',
|
||||
'',
|
||||
'n',
|
||||
'action',
|
||||
));
|
||||
$leased_table->setNoDataString('No tasks are leased by workers.');
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ class PhabricatorDaemonLogViewController extends PhabricatorDaemonController {
|
|||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$log = id(new PhabricatorDaemonLog())->load($this->id);
|
||||
if (!$log) {
|
||||
|
@ -37,6 +39,38 @@ class PhabricatorDaemonLogViewController extends PhabricatorDaemonController {
|
|||
|
||||
$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();
|
||||
foreach ($events as $event) {
|
||||
|
|
|
@ -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',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -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');
|
Loading…
Reference in a new issue