diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 89741038f6..a9ba1ba41d 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -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', diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index 85a47facc6..6628df4087 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -209,6 +209,7 @@ class AphrontDefaultApplicationConfiguration ), '/daemon/' => array( + 'task/(?P\d+)/$' => 'PhabricatorWorkerTaskDetailController', 'log/' => array( '(?P\d+)/$' => 'PhabricatorDaemonLogViewController', ), diff --git a/src/applications/daemon/controller/console/PhabricatorDaemonConsoleController.php b/src/applications/daemon/controller/console/PhabricatorDaemonConsoleController.php index 01cd05710a..aeaba5d4aa 100644 --- a/src/applications/daemon/controller/console/PhabricatorDaemonConsoleController.php +++ b/src/applications/daemon/controller/console/PhabricatorDaemonConsoleController.php @@ -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('
', $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.'); diff --git a/src/applications/daemon/controller/logview/PhabricatorDaemonLogViewController.php b/src/applications/daemon/controller/logview/PhabricatorDaemonLogViewController.php index 28f3c5477b..cf50e9a608 100644 --- a/src/applications/daemon/controller/logview/PhabricatorDaemonLogViewController.php +++ b/src/applications/daemon/controller/logview/PhabricatorDaemonLogViewController.php @@ -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) { diff --git a/src/applications/daemon/controller/workertaskdetail/PhabricatorWorkerTaskDetailController.php b/src/applications/daemon/controller/workertaskdetail/PhabricatorWorkerTaskDetailController.php new file mode 100644 index 0000000000..80fadc6047 --- /dev/null +++ b/src/applications/daemon/controller/workertaskdetail/PhabricatorWorkerTaskDetailController.php @@ -0,0 +1,95 @@ +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( + '

This task may have recently completed.

'); + $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', + )); + } + +} diff --git a/src/applications/daemon/controller/workertaskdetail/__init__.php b/src/applications/daemon/controller/workertaskdetail/__init__.php new file mode 100644 index 0000000000..3245ab7bf1 --- /dev/null +++ b/src/applications/daemon/controller/workertaskdetail/__init__.php @@ -0,0 +1,16 @@ +