mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
[更新]修改系统任务指定
This commit is contained in:
parent
9d6a82064d
commit
3a2e835e73
@ -62,11 +62,11 @@ class Listen extends Task
|
|||||||
throw new Exception("该任务{$item['id']}的处理子进程已经存在");
|
throw new Exception("该任务{$item['id']}的处理子进程已经存在");
|
||||||
} else {
|
} else {
|
||||||
$this->createProcess();
|
$this->createProcess();
|
||||||
$output->info(">>> 创建任务{$item['id']}的处理子进程成功");
|
$output->info("创建任务{$item['id']}的处理子进程成功");
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Db::name('SystemQueue')->where(['id' => $item['id']])->update(['status' => '4', 'desc' => $e->getMessage()]);
|
Db::name('SystemQueue')->where(['id' => $item['id']])->update(['status' => '4', 'desc' => $e->getMessage()]);
|
||||||
$output->error(">>> 创建任务{$item['id']}的处理进程失败,{$e->getMessage()}");
|
$output->error("创建任务{$item['id']}的处理进程失败,{$e->getMessage()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sleep(3);
|
sleep(3);
|
||||||
|
@ -32,7 +32,7 @@ class Start extends Task
|
|||||||
*/
|
*/
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this->setName('xqueue:start')->setDescription('检查并创建异步任务监听主进程');
|
$this->setName('xqueue:start')->setDescription('创建异步任务监听守护主进程');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +44,7 @@ class Start extends Task
|
|||||||
{
|
{
|
||||||
$this->cmd = "{$this->bin} xqueue:listen";
|
$this->cmd = "{$this->bin} xqueue:listen";
|
||||||
if (($pid = $this->checkProcess()) > 0) {
|
if (($pid = $this->checkProcess()) > 0) {
|
||||||
$output->writeln("异步任务监听主进程{$pid}已经启动!");
|
$output->info("异步任务监听主进程{$pid}已经启动!");
|
||||||
} else {
|
} else {
|
||||||
$this->createProcess();
|
$this->createProcess();
|
||||||
if (($pid = $this->checkProcess()) > 0) {
|
if (($pid = $this->checkProcess()) > 0) {
|
||||||
|
@ -31,7 +31,7 @@ class State extends Task
|
|||||||
*/
|
*/
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this->setName('xqueue:state')->setDescription('查看异步任务监听主进程的状态');
|
$this->setName('xqueue:state')->setDescription('查看异步任务监听主进程状态');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,9 +43,9 @@ class State extends Task
|
|||||||
{
|
{
|
||||||
$this->cmd = "{$this->bin} xqueue:listen";
|
$this->cmd = "{$this->bin} xqueue:listen";
|
||||||
if (($pid = $this->checkProcess()) > 0) {
|
if (($pid = $this->checkProcess()) > 0) {
|
||||||
$output->info(">>> 异步任务监听主进程{$pid}正在运行...");
|
$output->info("异步任务监听主进程{$pid}正在运行...");
|
||||||
} else {
|
} else {
|
||||||
$output->error(">>> 异步任务监听主进程没有运行哦^.^");
|
$output->error("异步任务监听主进程没有运行哦!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class Stop extends Task
|
|||||||
*/
|
*/
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this->setName('xqueue:stop')->setDescription('平滑停止异步任务守护的主进程');
|
$this->setName('xqueue:stop')->setDescription('平滑停止异步任务守护主进程');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,10 +43,11 @@ class Stop extends Task
|
|||||||
protected function execute(Input $input, Output $output)
|
protected function execute(Input $input, Output $output)
|
||||||
{
|
{
|
||||||
$this->cmd = "{$this->bin} xqueue:";
|
$this->cmd = "{$this->bin} xqueue:";
|
||||||
foreach ($this->queryProcess() as $item) {
|
if (count($processList = $this->queryProcess()) < 1) {
|
||||||
|
$output->writeln("没有需要结束的任务进程哦!");
|
||||||
|
} else foreach ($processList as $item) {
|
||||||
$this->closeProcess($item['pid']);
|
$this->closeProcess($item['pid']);
|
||||||
$output->writeln(">>> 发送结束进程{$item['pid']}指令成功");
|
$output->writeln("发送结束任务进程{$item['pid']}指令成功!");
|
||||||
}
|
}
|
||||||
$output->info(">>> 所有异步任务进程的结束指令发送成功");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,10 +67,10 @@ class Work extends Task
|
|||||||
if (empty($this->id)) throw new Exception("执行任务需要指定任务编号!");
|
if (empty($this->id)) throw new Exception("执行任务需要指定任务编号!");
|
||||||
$queue = Db::name('SystemQueue')->where(['id' => $this->id, 'status' => '2'])->find();
|
$queue = Db::name('SystemQueue')->where(['id' => $this->id, 'status' => '2'])->find();
|
||||||
if (empty($queue)) throw new Exception("执行任务{$this->id}的信息或状态异常!");
|
if (empty($queue)) throw new Exception("执行任务{$this->id}的信息或状态异常!");
|
||||||
|
// 设置进程标题
|
||||||
if ($this->isWin() && function_exists('cli_set_process_title')) {
|
if ($this->isWin() && function_exists('cli_set_process_title')) {
|
||||||
cli_set_process_title("ThinkAdmin {$this->version} 异步任务执行子进程 - {$queue['title']}");
|
cli_set_process_title("ThinkAdmin {$this->version} 异步任务执行子进程 - {$queue['title']}");
|
||||||
}
|
}
|
||||||
// 设置进程标题
|
|
||||||
// 执行任务内容
|
// 执行任务内容
|
||||||
if (class_exists($queue['preload'])) {
|
if (class_exists($queue['preload'])) {
|
||||||
if (method_exists($class = new $queue['preload'], 'execute')) {
|
if (method_exists($class = new $queue['preload'], 'execute')) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user