mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
增加任务记录清理操作
This commit is contained in:
parent
77feb27dc1
commit
d97b0a248e
@ -97,7 +97,11 @@ class Queue extends Controller
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$message = nl2br($this->app->console->call('xtask:start')->fetch());
|
$message = nl2br($this->app->console->call('xtask:start')->fetch());
|
||||||
preg_match('/主进程\d+/', $message, $attr) ? $this->success($message) : $this->error($message);
|
if (preg_match('/process.*?\d+/', $message, $attr)) {
|
||||||
|
$this->success('任务监听主进程启动成功!');
|
||||||
|
} else {
|
||||||
|
$this->error($message);
|
||||||
|
}
|
||||||
} catch (HttpResponseException $exception) {
|
} catch (HttpResponseException $exception) {
|
||||||
throw $exception;
|
throw $exception;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -105,6 +109,22 @@ class Queue extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理3天前的记录
|
||||||
|
* @auth true
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
*/
|
||||||
|
public function clear()
|
||||||
|
{
|
||||||
|
$map = [['exec_time', '<', strtotime('-3days')]];
|
||||||
|
$result = $this->app->db->name($this->table)->where($map)->delete();
|
||||||
|
if ($result !== false) {
|
||||||
|
$this->success('成功清理3天前的任务记录!');
|
||||||
|
} else {
|
||||||
|
$this->error('清理3天前的任务记录失败!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WIN停止监听进程
|
* WIN停止监听进程
|
||||||
* @auth true
|
* @auth true
|
||||||
@ -113,7 +133,13 @@ class Queue extends Controller
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$message = nl2br($this->app->console->call('xtask:stop')->fetch());
|
$message = nl2br($this->app->console->call('xtask:stop')->fetch());
|
||||||
stripos($message, '成功') !== false ? $this->success($message) : $this->error($message);
|
if (stripos($message, 'succeeded')) {
|
||||||
|
$this->success('停止任务监听主进程成功!');
|
||||||
|
} elseif (stripos($message, 'finish')) {
|
||||||
|
$this->success('没有找到需要停止的进程!');
|
||||||
|
} else {
|
||||||
|
$this->error($message);
|
||||||
|
}
|
||||||
} catch (HttpResponseException $exception) {
|
} catch (HttpResponseException $exception) {
|
||||||
throw $exception;
|
throw $exception;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -14,6 +14,10 @@
|
|||||||
<button data-action='{:url("remove")}' data-rule="id#{key}" data-confirm="确定批量删除任务吗?" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</button>
|
<button data-action='{:url("remove")}' data-rule="id#{key}" data-confirm="确定批量删除任务吗?" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{if auth("clear")}
|
||||||
|
<button data-load='{:url("clear")}' data-confirm="确定要清理3天前的任务记录吗?" class='layui-btn layui-btn-sm layui-btn-primary'>清理记录</button>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
{block name="content"}
|
{block name="content"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user