mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-05-23 23:29:19 +08:00
ComposerUpdate
This commit is contained in:
parent
9a14e8dbe5
commit
547c3eb488
8
composer.lock
generated
8
composer.lock
generated
@ -783,12 +783,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||
"reference": "82a60f7d4b2362e27318e696a231a124e5c2c793"
|
||||
"reference": "9e3ecc257550a11f7bdffa7a1c6c6488e7b1453f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/82a60f7d4b2362e27318e696a231a124e5c2c793",
|
||||
"reference": "82a60f7d4b2362e27318e696a231a124e5c2c793",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/9e3ecc257550a11f7bdffa7a1c6c6488e7b1453f",
|
||||
"reference": "9e3ecc257550a11f7bdffa7a1c6c6488e7b1453f",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -832,7 +832,7 @@
|
||||
],
|
||||
"description": "ThinkPHP v6.0 Development Library",
|
||||
"homepage": "http://framework.thinkadmin.top",
|
||||
"time": "2019-12-02T02:46:31+00:00"
|
||||
"time": "2019-12-02T03:28:58+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -805,12 +805,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||
"reference": "82a60f7d4b2362e27318e696a231a124e5c2c793"
|
||||
"reference": "9e3ecc257550a11f7bdffa7a1c6c6488e7b1453f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/82a60f7d4b2362e27318e696a231a124e5c2c793",
|
||||
"reference": "82a60f7d4b2362e27318e696a231a124e5c2c793",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/9e3ecc257550a11f7bdffa7a1c6c6488e7b1453f",
|
||||
"reference": "9e3ecc257550a11f7bdffa7a1c6c6488e7b1453f",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -826,7 +826,7 @@
|
||||
"ext-json": "*",
|
||||
"topthink/framework": "^6.0"
|
||||
},
|
||||
"time": "2019-12-02T02:46:31+00:00",
|
||||
"time": "2019-12-02T03:28:58+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"think": {
|
||||
|
2
vendor/services.php
vendored
2
vendor/services.php
vendored
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// This file is automatically generated at:2019-12-02 10:51:21
|
||||
// This file is automatically generated at:2019-12-02 11:32:38
|
||||
declare (strict_types = 1);
|
||||
return array (
|
||||
0 => 'think\\app\\Service',
|
||||
|
@ -60,34 +60,45 @@ class WorkQueue extends Command
|
||||
*/
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
try {
|
||||
set_time_limit(0);
|
||||
$this->code = trim($input->getArgument('code'));
|
||||
if (empty($this->code)) throw new Exception("执行任务需要指定任务编号!");
|
||||
set_time_limit(0);
|
||||
$this->code = trim($input->getArgument('code'));
|
||||
if (empty($this->code)) {
|
||||
$this->output->error('执行任务需要指定任务编号!');
|
||||
} else try {
|
||||
$queue = $this->app->db->name('SystemQueue')->where(['code' => $this->code, 'status' => '1'])->find();
|
||||
if (empty($queue)) throw new Exception("执行任务{$this->code}的信息或状态异常!");
|
||||
// 锁定任务状态
|
||||
$this->app->db->name('SystemQueue')->where(['code' => $this->code])->update([
|
||||
'status' => '2', 'enter_time' => time(), 'exec_desc' => '', 'attempts' => $this->app->db->raw('attempts+1'),
|
||||
]);
|
||||
// 设置进程标题
|
||||
if (($process = ProcessService::instance())->iswin()) {
|
||||
$this->setProcessTitle("ThinkAdmin {$process->version()} 执行任务 - {$queue['title']}");
|
||||
}
|
||||
// 执行任务内容
|
||||
if (class_exists($command = $queue['command'])) {
|
||||
if ($command instanceof QueueService) {
|
||||
$data = json_decode($queue['data'], true) ?: [];
|
||||
$this->update('3', $command::instance()->initialize($this->code)->execute($data));
|
||||
} else {
|
||||
throw new Exception("任务处理类 {$command} 未继承 think\\admin\\service\\QueueService");
|
||||
}
|
||||
if (empty($queue)) {
|
||||
// 这里不做任何处理(该任务可能在其它地方已经在执行)
|
||||
$this->output->warning($message = "执行任务{$this->code}的或状态异常!");
|
||||
} else {
|
||||
$attr = explode(' ', trim(preg_replace('|\s+|', ' ', $queue['command'])));
|
||||
$this->update('3', $this->app->console->call(array_shift($attr), $attr, 'console'));
|
||||
// 锁定任务状态
|
||||
$this->app->db->name('SystemQueue')->where(['code' => $this->code])->update([
|
||||
'status' => '2', 'enter_time' => time(), 'exec_desc' => '', 'attempts' => $this->app->db->raw('attempts+1'),
|
||||
]);
|
||||
// 设置进程标题
|
||||
if (($process = ProcessService::instance())->iswin()) {
|
||||
$this->setProcessTitle("ThinkAdmin {$process->version()} 执行任务 - {$queue['title']}");
|
||||
}
|
||||
// 执行任务内容
|
||||
if (class_exists($command = $queue['command'])) {
|
||||
// 自定义服务,支持返回消息(支持异常结束,异常码可选择 3|4 设置任务状态)
|
||||
if ($command instanceof QueueService) {
|
||||
$data = json_decode($queue['data'], true) ?: [];
|
||||
$this->update('3', $command::instance()->initialize($this->code)->execute($data));
|
||||
} else {
|
||||
throw new Exception("任务处理类 {$command} 未继承 think\\admin\\service\\QueueService");
|
||||
}
|
||||
} else {
|
||||
// 自定义指令,不支持返回消息(支持异常结束,异常码可选择 3|4 设置任务状态)
|
||||
$attr = explode(' ', trim(preg_replace('|\s+|', ' ', $queue['command'])));
|
||||
$this->update('3', $this->app->console->call(array_shift($attr), $attr, 'console'));
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->update('4', $e->getMessage());
|
||||
if (in_array($e->getCode(), ['3', '4'])) {
|
||||
$this->update($e->getCode(), $e->getMessage());
|
||||
} else {
|
||||
$this->update('4', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user