From a60441174d4e7c704f38f2e1e2afd9f0d6c28e8e Mon Sep 17 00:00:00 2001 From: Anyon Date: Mon, 6 Jan 2020 15:57:25 +0800 Subject: [PATCH] CompoerUpdate --- admin_v6.sql | 39 ++++++++++--------- app/admin/view/queue/index.html | 9 ++--- composer.lock | 8 ++-- vendor/composer/installed.json | 8 ++-- vendor/services.php | 2 +- .../think-library/src/queue/ListenQueue.php | 5 +-- .../think-library/src/queue/WorkQueue.php | 5 +-- 7 files changed, 35 insertions(+), 41 deletions(-) diff --git a/admin_v6.sql b/admin_v6.sql index c8fa74291..54c1d638c 100644 --- a/admin_v6.sql +++ b/admin_v6.sql @@ -172,28 +172,29 @@ CREATE TABLE `system_oplog` ( -- Table structure for system_queue -- ---------------------------- DROP TABLE IF EXISTS `system_queue`; -CREATE TABLE `system_queue` ( +CREATE TABLE `system_queue` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, - `code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '任务编号', - `title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '任务名称', - `command` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '执行指令', - `exec_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '执行参数', - `exec_time` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '执行时间', - `exec_desc` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '状态描述', - `enter_time` decimal(20, 4) NULL DEFAULT 0.0000 COMMENT '开始时间', - `outer_time` decimal(20, 4) NULL DEFAULT 0.0000 COMMENT '结束时间', - `attempts` bigint(20) NULL DEFAULT 0 COMMENT '执行次数', - `rscript` tinyint(1) NULL DEFAULT 1 COMMENT '单例模式', - `status` tinyint(1) NULL DEFAULT 1 COMMENT '任务状态(1新任务,2处理中,3成功,4失败)', + `code` varchar(20) NOT NULL DEFAULT '' COMMENT '任务编号', + `title` varchar(50) NOT NULL DEFAULT '' COMMENT '任务名称', + `command` varchar(500) DEFAULT '' COMMENT '执行指令', + `exec_pid` bigint(20) DEFAULT '0' COMMENT '执行进程', + `exec_data` longtext COMMENT '执行参数', + `exec_time` bigint(20) DEFAULT '0' COMMENT '执行时间', + `exec_desc` varchar(500) DEFAULT '' COMMENT '状态描述', + `enter_time` decimal(20,4) DEFAULT '0.0000' COMMENT '开始时间', + `outer_time` decimal(20,4) DEFAULT '0.0000' COMMENT '结束时间', + `attempts` bigint(20) DEFAULT '0' COMMENT '执行次数', + `rscript` tinyint(1) DEFAULT '1' COMMENT '执行模式(0单例,1多例)', + `status` tinyint(1) DEFAULT '1' COMMENT '任务状态(1新任务,2处理中,3成功,4失败)', `create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_system_queue_code`(`code`) USING BTREE, - INDEX `idx_system_queue_title`(`title`) USING BTREE, - INDEX `idx_system_queue_status`(`status`) USING BTREE, - INDEX `idx_system_queue_rscript`(`rscript`) USING BTREE, - INDEX `idx_system_queue_create_at`(`create_at`) USING BTREE, - INDEX `idx_system_queue_exec_time`(`exec_time`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-任务'; + KEY `idx_system_queue_code` (`code`) USING BTREE, + KEY `idx_system_queue_title` (`title`) USING BTREE, + KEY `idx_system_queue_status` (`status`) USING BTREE, + KEY `idx_system_queue_rscript` (`rscript`) USING BTREE, + KEY `idx_system_queue_create_at` (`create_at`) USING BTREE, + KEY `idx_system_queue_exec_time` (`exec_time`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='系统-任务'; -- ---------------------------- -- Table structure for system_user diff --git a/app/admin/view/queue/index.html b/app/admin/view/queue/index.html index 658520d0a..26e3c8099 100644 --- a/app/admin/view/queue/index.html +++ b/app/admin/view/queue/index.html @@ -79,14 +79,11 @@ 任务指令:{$vo.command|default=''} - 计划时间:{$vo.exec_time|format_datetime}
+ 计划时间:{$vo.exec_time|format_datetime} {if isset($vo.exec_pid) and $vo.exec_pid>0}( 进程 {$vo.exec_pid|default='-'} ){/if}
{if $vo.status eq 3 or $vo.status eq 4} 执行时间:{$vo.enter_time|format_datetime}( 耗时 {:sprintf("%.4f",$vo.outer_time-$vo.enter_time)} 秒 ) - {elseif $vo.status eq 2} - 开始时间:{$vo.enter_time|format_datetime} - {else} - 创建时间:{$vo.create_at|format_datetime} - {/if} + {elseif $vo.status eq 2} 开始时间:{$vo.enter_time|format_datetime} + {else} 创建时间:{$vo.create_at|format_datetime} {/if} diff --git a/composer.lock b/composer.lock index e242b535b..fa960e4d8 100644 --- a/composer.lock +++ b/composer.lock @@ -909,12 +909,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "cfd590be48a94d97e986cc67e2043a8b96611371" + "reference": "da9b19733aa956650b201c1351886ac045119453" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/cfd590be48a94d97e986cc67e2043a8b96611371", - "reference": "cfd590be48a94d97e986cc67e2043a8b96611371", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/da9b19733aa956650b201c1351886ac045119453", + "reference": "da9b19733aa956650b201c1351886ac045119453", "shasum": "", "mirrors": [ { @@ -958,7 +958,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://framework.thinkadmin.top", - "time": "2020-01-06T07:30:03+00:00" + "time": "2020-01-06T07:42:55+00:00" }, { "name": "zoujingli/wechat-developer", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 7d136e64d..7701c0a8f 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -935,12 +935,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "cfd590be48a94d97e986cc67e2043a8b96611371" + "reference": "da9b19733aa956650b201c1351886ac045119453" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/cfd590be48a94d97e986cc67e2043a8b96611371", - "reference": "cfd590be48a94d97e986cc67e2043a8b96611371", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/da9b19733aa956650b201c1351886ac045119453", + "reference": "da9b19733aa956650b201c1351886ac045119453", "shasum": "", "mirrors": [ { @@ -956,7 +956,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2020-01-06T07:30:03+00:00", + "time": "2020-01-06T07:42:55+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index 8be36a0d9..50ab0ef6a 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/zoujingli/think-library/src/queue/ListenQueue.php b/vendor/zoujingli/think-library/src/queue/ListenQueue.php index 34e84a6da..900f1a3ad 100644 --- a/vendor/zoujingli/think-library/src/queue/ListenQueue.php +++ b/vendor/zoujingli/think-library/src/queue/ListenQueue.php @@ -49,8 +49,7 @@ class ListenQueue extends Command * @param Output $output 输出对象 */ protected function execute(Input $input, Output $output) - { $this->output->writeln('进程'); - $this->output->writeln(getmypid()); + { set_time_limit(0); $this->app->db->name('SystemQueue')->count(); if (($this->process = ProcessService::instance())->iswin()) { @@ -86,8 +85,6 @@ class ListenQueue extends Command */ protected function update($code, array $data = []) { - - return $this->app->db->name('SystemQueue')->where(['code' => $code])->update($data); } diff --git a/vendor/zoujingli/think-library/src/queue/WorkQueue.php b/vendor/zoujingli/think-library/src/queue/WorkQueue.php index 11b0249f9..13b463bab 100644 --- a/vendor/zoujingli/think-library/src/queue/WorkQueue.php +++ b/vendor/zoujingli/think-library/src/queue/WorkQueue.php @@ -73,8 +73,7 @@ class WorkQueue extends Command } else { // 锁定任务状态 $this->app->db->name($this->table)->strict(false)->where(['code' => $this->code])->update([ - 'status' => '2', 'enter_time' => microtime(true), 'outer_time' => '0', - 'exec_pid' => getmygid(), 'exec_desc' => '', 'attempts' => $this->app->db->raw('attempts+1'), + 'status' => '2', 'enter_time' => microtime(true), 'outer_time' => '0', 'exec_pid' => getmypid(), 'exec_desc' => '', 'attempts' => $this->app->db->raw('attempts+1'), ]); // 设置进程标题 if (($process = ProcessService::instance())->iswin()) { @@ -115,7 +114,7 @@ class WorkQueue extends Command { $desc = explode("\n", trim(is_string($message) ? $message : '')); $result = $this->app->db->name($this->table)->strict(false)->where(['code' => $this->code])->update([ - 'status' => $status, 'outer_time' => microtime(true), 'exec_pid' => getmygid(), 'exec_desc' => $desc[0], + 'status' => $status, 'outer_time' => microtime(true), 'exec_pid' => getmypid(), 'exec_desc' => $desc[0], ]); $this->output->writeln(is_string($message) ? $message : ''); return $result == false;