diff --git a/composer.lock b/composer.lock index 84e376a1e..ab4cd06a9 100644 --- a/composer.lock +++ b/composer.lock @@ -504,7 +504,7 @@ }, { "name": "symfony/options-resolver", - "version": "v3.4.41", + "version": "v3.4.42", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", @@ -929,12 +929,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "334cd213e194ffaaa882bbcd5fa5d5e58ac51bab" + "reference": "60e7ef58637b5efdf08d8a8dd5199c183272f655" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/334cd213e194ffaaa882bbcd5fa5d5e58ac51bab", - "reference": "334cd213e194ffaaa882bbcd5fa5d5e58ac51bab", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/60e7ef58637b5efdf08d8a8dd5199c183272f655", + "reference": "60e7ef58637b5efdf08d8a8dd5199c183272f655", "shasum": "", "mirrors": [ { @@ -978,7 +978,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://framework.thinkadmin.top", - "time": "2020-06-07T15:00:59+00:00" + "time": "2020-06-16T08:08:00+00:00" }, { "name": "zoujingli/wechat-developer", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 2564db327..a22e2edc2 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -513,8 +513,8 @@ }, { "name": "symfony/options-resolver", - "version": "v3.4.41", - "version_normalized": "3.4.41.0", + "version": "v3.4.42", + "version_normalized": "3.4.42.0", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", @@ -955,12 +955,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "334cd213e194ffaaa882bbcd5fa5d5e58ac51bab" + "reference": "60e7ef58637b5efdf08d8a8dd5199c183272f655" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/334cd213e194ffaaa882bbcd5fa5d5e58ac51bab", - "reference": "334cd213e194ffaaa882bbcd5fa5d5e58ac51bab", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/60e7ef58637b5efdf08d8a8dd5199c183272f655", + "reference": "60e7ef58637b5efdf08d8a8dd5199c183272f655", "shasum": "", "mirrors": [ { @@ -976,7 +976,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2020-06-07T15:00:59+00:00", + "time": "2020-06-16T08:08:00+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index 8ff89c382..fb2f3687c 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/zoujingli/think-library/src/command/Install.php b/vendor/zoujingli/think-library/src/command/Install.php index dd6f56c17..d56eef292 100644 --- a/vendor/zoujingli/think-library/src/command/Install.php +++ b/vendor/zoujingli/think-library/src/command/Install.php @@ -132,7 +132,6 @@ class Install extends Command protected function installData() { - } } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/command/Queue.php b/vendor/zoujingli/think-library/src/command/Queue.php index 9e6245b92..0a8db646c 100644 --- a/vendor/zoujingli/think-library/src/command/Queue.php +++ b/vendor/zoujingli/think-library/src/command/Queue.php @@ -183,23 +183,27 @@ class Queue extends Command { // 清理 7 天前的历史任务记录 $map = [['exec_time', '<', time() - 7 * 24 * 3600]]; - $count = $this->app->db->name($this->table)->where($map)->delete(); - $this->setQueueProgress("本次清理了 {$count} 条历史任务记录"); - // 标记超过 1 小时未完成的任务为失败状态 - $map = [['exec_time', '<', time() - 3600], ['status', '=', '2']]; - list($used, $total) = [0, $this->app->db->name($this->table)->where($map)->count()]; - $this->app->db->name($this->table)->where($map)->chunk(100, function (Collection $result) use ($total, &$used) { + $clear = $this->app->db->name($this->table)->where($map)->delete(); + $this->setQueueProgress("本次清理了 {$clear} 条历史任务记录"); + // 标记超过 1 小时未完成的任务为失败状态,循环任务失败重置 + $map1 = [['loops_time', '>', 0], ['status', '=', 4]]; // 执行失败的循环任务 + $map2 = [['exec_time', '<', time() - 3600], ['status', '=', 2]]; // 执行超时的任务 + [$timeout, $loops, $total] = [0, 0, $this->app->db->name($this->table)->whereOr([$map1, $map2])->count()]; + $this->app->db->name($this->table)->whereOr([$map1, $map2])->chunk(100, function (Collection $result) use ($total, &$loops, &$timeout) { foreach ($result->toArray() as $item) { - $stridx = str_pad(++$used, strlen("{$total}"), '0', STR_PAD_LEFT) . "/{$total}"; - $this->setQueueProgress("[{$stridx}] 正在标记任务 {$item['code']} 超时", $used / $total * 100); - $item['loops_time'] > 0 ? $this->app->db->name($this->table)->where(['id' => $item['id']])->update([ - 'status' => 2, 'exec_desc' => '任务执行超时,已自动重置任务待!', - ]) : $this->app->db->name($this->table)->where(['id' => $item['id']])->update([ - 'status' => 4, 'exec_desc' => '任务执行超时,已自动标识为失败!', - ]); + $item['loops_time'] > 0 ? $loops++ : $timeout++; + $prefix = str_pad($timeout + $loops, strlen("{$total}"), '0', STR_PAD_LEFT); + if ($item['loops_time'] > 0) { + $this->setQueueProgress("[{$prefix}/{$total}] 正在重置任务 {$item['code']} 为运行", ($timeout + $loops) * 100 / $total); + [$status, $message] = [1, intval($item['status']) === 4 ? '任务执行失败,已自动重置任务!' : '任务执行超时,已自动重置任务!']; + } else { + $this->setQueueProgress("[{$prefix}/{$total}] 正在标记任务 {$item['code']} 为超时", ($timeout + $loops) * 100 / $total); + [$status, $message] = [4, '任务执行超时,已自动标识为失败!']; + } + $this->app->db->name($this->table)->where(['id' => $item['id']])->update(['status' => $status, 'exec_desc' => $message]); } }); - $this->setQueueSuccess("清理 {$count} 条历史任务,标识 {$total} 条超时任务"); + $this->setQueueSuccess("清理 {$clear} 条历史任务,关闭 {$timeout} 条超时任务,重置 {$loops} 条循环任务"); } /** diff --git a/vendor/zoujingli/think-library/src/service/InstallService.php b/vendor/zoujingli/think-library/src/service/InstallService.php index b65c30e0e..e995d1c76 100644 --- a/vendor/zoujingli/think-library/src/service/InstallService.php +++ b/vendor/zoujingli/think-library/src/service/InstallService.php @@ -138,8 +138,8 @@ class InstallService extends Service public function grenerateDifference($rules = [], $ignore = []) { list($this->rules, $this->ignore, $data) = [$rules, $ignore, []]; - $result = json_decode(HttpExtend::post("{$this->uri}?s=/admin/api.update/tree", [ - 'rules' => serialize($this->rules), 'ignore' => serialize($this->ignore), + $result = json_decode(HttpExtend::post("{$this->uri}?s=/admin/api.update/node", [ + 'rules' => json_encode($this->rules), 'ignore' => json_encode($this->ignore), ]), true); if (!empty($result['code'])) { $new = $this->getList($result['data']['rules'], $result['data']['ignore']);