mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
[更新]增加任务启动数据库检查
This commit is contained in:
parent
2ab2f66557
commit
9546b9a668
@ -48,6 +48,7 @@ class Listen extends Task
|
|||||||
*/
|
*/
|
||||||
protected function execute(Input $input, Output $output)
|
protected function execute(Input $input, Output $output)
|
||||||
{
|
{
|
||||||
|
Db::name('SystemQueue')->count();
|
||||||
$output->comment('============ 异步任务监听中 ============');
|
$output->comment('============ 异步任务监听中 ============');
|
||||||
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} 异步任务监听主进程");
|
cli_set_process_title("ThinkAdmin {$this->version} 异步任务监听主进程");
|
||||||
@ -60,7 +61,7 @@ class Listen extends Task
|
|||||||
$command = env('runtime_path') . "queue/{$item['id']}.cmd";
|
$command = env('runtime_path') . "queue/{$item['id']}.cmd";
|
||||||
file_exists(dirname($command)) or mkdir(dirname($command), 0755, true);
|
file_exists(dirname($command)) or mkdir(dirname($command), 0755, true);
|
||||||
file_put_contents($command, "{$this->bin} xtask:_work {$item['id']} -" . PHP_EOL . 'del %~dp0%0 /y');
|
file_put_contents($command, "{$this->bin} xtask:_work {$item['id']} -" . PHP_EOL . 'del %~dp0%0 /y');
|
||||||
$this->cmd = __DIR__ . DIRECTORY_SEPARATOR . "bin/process.exe {$command}";
|
$this->cmd = __DIR__ . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "process.exe {$command}";
|
||||||
} else {
|
} else {
|
||||||
$this->cmd = "{$this->bin} xtask:_work {$item['id']} -";
|
$this->cmd = "{$this->bin} xtask:_work {$item['id']} -";
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ namespace app\admin\queue\task;
|
|||||||
use library\command\Task;
|
use library\command\Task;
|
||||||
use think\console\Input;
|
use think\console\Input;
|
||||||
use think\console\Output;
|
use think\console\Output;
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查并创建异步任务监听主进程
|
* 检查并创建异步任务监听主进程
|
||||||
@ -42,6 +43,7 @@ class Start extends Task
|
|||||||
*/
|
*/
|
||||||
protected function execute(Input $input, Output $output)
|
protected function execute(Input $input, Output $output)
|
||||||
{
|
{
|
||||||
|
Db::name('SystemQueue')->count();
|
||||||
$this->setBaseProcess();
|
$this->setBaseProcess();
|
||||||
if (($pid = $this->checkProcess()) > 0) {
|
if (($pid = $this->checkProcess()) > 0) {
|
||||||
$output->info("异步任务监听主进程{$pid}已经启动!");
|
$output->info("异步任务监听主进程{$pid}已经启动!");
|
||||||
@ -70,7 +72,7 @@ class Start extends Task
|
|||||||
$command = env('runtime_path') . "queue" . DIRECTORY_SEPARATOR . "listen.cmd";
|
$command = env('runtime_path') . "queue" . DIRECTORY_SEPARATOR . "listen.cmd";
|
||||||
file_exists(dirname($command)) or mkdir(dirname($command), 0755, true);
|
file_exists(dirname($command)) or mkdir(dirname($command), 0755, true);
|
||||||
file_put_contents($command, $this->cmd . PHP_EOL . 'del %~dp0%0 /y');
|
file_put_contents($command, $this->cmd . PHP_EOL . 'del %~dp0%0 /y');
|
||||||
$this->cmd = __DIR__ . DIRECTORY_SEPARATOR . "/bin/process.exe {$command}";
|
$this->cmd = __DIR__ . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "process.exe {$command}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user