ComposerUpdate

This commit is contained in:
Anyon 2019-12-02 11:33:00 +08:00
parent 9a14e8dbe5
commit 547c3eb488
4 changed files with 44 additions and 33 deletions

8
composer.lock generated
View File

@ -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": [],

View File

@ -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
View File

@ -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',

View File

@ -60,12 +60,16 @@ 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("执行任务需要指定任务编号!");
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}的信息或状态异常!");
if (empty($queue)) {
// 这里不做任何处理(该任务可能在其它地方已经在执行)
$this->output->warning($message = "执行任务{$this->code}的或状态异常!");
} else {
// 锁定任务状态
$this->app->db->name('SystemQueue')->where(['code' => $this->code])->update([
'status' => '2', 'enter_time' => time(), 'exec_desc' => '', 'attempts' => $this->app->db->raw('attempts+1'),
@ -76,6 +80,7 @@ class WorkQueue extends Command
}
// 执行任务内容
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));
@ -83,13 +88,19 @@ class WorkQueue extends Command
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) {
if (in_array($e->getCode(), ['3', '4'])) {
$this->update($e->getCode(), $e->getMessage());
} else {
$this->update('4', $e->getMessage());
}
}
}
/**
* 修改当前任务状态