new: Added a way to clear worker queues

pull/1438/head
iglocska 2016-08-16 00:46:41 +02:00
parent 33ea77d90b
commit 28a76076f7
2 changed files with 19 additions and 2 deletions

View File

@ -1096,6 +1096,16 @@ class ServersController extends AppController {
}
$this->redirect('/servers/serverSettings/diagnostics');
}
public function clearWorkerQueue($worker) {
if (!$this->_isSiteAdmin() || !$this->request->is('Post') || $this->request->is('ajax')) throw new MethodNotAllowedException();
$worker_array = array('cache', 'default', 'email', 'prio');
if (!in_array($worker, $worker_array)) throw new MethodNotAllowedException('Invalid worker');
$redis = Resque::redis();
$redis->del('queue:' . $worker);
$this->Session->setFlash('Queue cleared.');
$this->redirect($this->referer());
}
public function getVersion() {
if (!$this->userRole['perm_auth']) throw new MethodNotAllowedException('This action requires API access.');

View File

@ -29,7 +29,14 @@
?>
<h3><?php echo 'Worker type: ' . h($type);?></h3>
<?php if ($type !== 'scheduler'): ?>
<p><b>Jobs in the queue: </b><?php echo h($data['jobCount']);?></p>
<span><b>Jobs in the queue: </b>
<?php
echo h($data['jobCount']);
if ($data['jobCount'] > 0) {
echo $this->Form->postLink('<span class="icon-trash useCursorPointer"></span>', $baseurl . '/servers/clearWorkerQueue/' . h($type), array('escape' => false, 'inline' => true, 'style' => 'margin-left:2px;'));
}
?>
</span>
<p><b>Queue status: </b>
<?php
$color = "green";
@ -111,4 +118,4 @@
<?php echo $this->Form->create('Server', array('url' => '/servers/restartWorkers'));
echo $this->Form->button('Restart all workers', array('class' => 'btn btn-primary'));
echo $this->Form->end();
?>
?>