CompoerUpdate

This commit is contained in:
Anyon 2020-01-06 15:57:25 +08:00
parent c285caef3d
commit a60441174d
7 changed files with 35 additions and 41 deletions

View File

@ -172,28 +172,29 @@ CREATE TABLE `system_oplog` (
-- Table structure for system_queue -- Table structure for system_queue
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `system_queue`; DROP TABLE IF EXISTS `system_queue`;
CREATE TABLE `system_queue` ( CREATE TABLE `system_queue` (
`id` bigint(20) NOT NULL AUTO_INCREMENT, `id` bigint(20) NOT NULL AUTO_INCREMENT,
`code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '任务编号', `code` varchar(20) NOT NULL DEFAULT '' COMMENT '任务编号',
`title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '任务名称', `title` varchar(50) NOT NULL DEFAULT '' COMMENT '任务名称',
`command` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '执行指令', `command` varchar(500) DEFAULT '' COMMENT '执行指令',
`exec_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '执行参数', `exec_pid` bigint(20) DEFAULT '0' COMMENT '执行进程',
`exec_time` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '执行时间', `exec_data` longtext COMMENT '执行参数',
`exec_desc` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '状态描述', `exec_time` bigint(20) DEFAULT '0' COMMENT '执行时间',
`enter_time` decimal(20, 4) NULL DEFAULT 0.0000 COMMENT '开始时间', `exec_desc` varchar(500) DEFAULT '' COMMENT '状态描述',
`outer_time` decimal(20, 4) NULL DEFAULT 0.0000 COMMENT '结束时间', `enter_time` decimal(20,4) DEFAULT '0.0000' COMMENT '开始时间',
`attempts` bigint(20) NULL DEFAULT 0 COMMENT '执行次数', `outer_time` decimal(20,4) DEFAULT '0.0000' COMMENT '结束时间',
`rscript` tinyint(1) NULL DEFAULT 1 COMMENT '单例模式', `attempts` bigint(20) DEFAULT '0' COMMENT '执行次数',
`status` tinyint(1) NULL DEFAULT 1 COMMENT '任务状态(1新任务,2处理中,3成功,4失败)', `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 '创建时间', `create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_system_queue_code`(`code`) USING BTREE, KEY `idx_system_queue_code` (`code`) USING BTREE,
INDEX `idx_system_queue_title`(`title`) USING BTREE, KEY `idx_system_queue_title` (`title`) USING BTREE,
INDEX `idx_system_queue_status`(`status`) USING BTREE, KEY `idx_system_queue_status` (`status`) USING BTREE,
INDEX `idx_system_queue_rscript`(`rscript`) USING BTREE, KEY `idx_system_queue_rscript` (`rscript`) USING BTREE,
INDEX `idx_system_queue_create_at`(`create_at`) USING BTREE, KEY `idx_system_queue_create_at` (`create_at`) USING BTREE,
INDEX `idx_system_queue_exec_time`(`exec_time`) USING BTREE KEY `idx_system_queue_exec_time` (`exec_time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-任务'; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='系统-任务';
-- ---------------------------- -- ----------------------------
-- Table structure for system_user -- Table structure for system_user

View File

@ -79,14 +79,11 @@
<span class="color-desc">任务指令:{$vo.command|default=''}</span> <span class="color-desc">任务指令:{$vo.command|default=''}</span>
</td> </td>
<td class='text-left nowrap'> <td class='text-left nowrap'>
计划时间:{$vo.exec_time|format_datetime}<br> 计划时间:{$vo.exec_time|format_datetime} {if isset($vo.exec_pid) and $vo.exec_pid>0} 进程 <b class="color-blue">{$vo.exec_pid|default='-'}</b> {/if}<br>
{if $vo.status eq 3 or $vo.status eq 4} {if $vo.status eq 3 or $vo.status eq 4}
执行时间:{$vo.enter_time|format_datetime} 耗时 <b class="color-blue">{:sprintf("%.4f",$vo.outer_time-$vo.enter_time)}</b> 执行时间:{$vo.enter_time|format_datetime} 耗时 <b class="color-blue">{:sprintf("%.4f",$vo.outer_time-$vo.enter_time)}</b>
{elseif $vo.status eq 2} {elseif $vo.status eq 2} 开始时间:{$vo.enter_time|format_datetime}
开始时间:{$vo.enter_time|format_datetime} {else} 创建时间:{$vo.create_at|format_datetime} {/if}
{else}
创建时间:{$vo.create_at|format_datetime}
{/if}
</td> </td>
<td class='text-left nowrap'> <td class='text-left nowrap'>

8
composer.lock generated
View File

@ -909,12 +909,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "cfd590be48a94d97e986cc67e2043a8b96611371" "reference": "da9b19733aa956650b201c1351886ac045119453"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/cfd590be48a94d97e986cc67e2043a8b96611371", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/da9b19733aa956650b201c1351886ac045119453",
"reference": "cfd590be48a94d97e986cc67e2043a8b96611371", "reference": "da9b19733aa956650b201c1351886ac045119453",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -958,7 +958,7 @@
], ],
"description": "ThinkPHP v6.0 Development Library", "description": "ThinkPHP v6.0 Development Library",
"homepage": "http://framework.thinkadmin.top", "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", "name": "zoujingli/wechat-developer",

View File

@ -935,12 +935,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "cfd590be48a94d97e986cc67e2043a8b96611371" "reference": "da9b19733aa956650b201c1351886ac045119453"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/cfd590be48a94d97e986cc67e2043a8b96611371", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/da9b19733aa956650b201c1351886ac045119453",
"reference": "cfd590be48a94d97e986cc67e2043a8b96611371", "reference": "da9b19733aa956650b201c1351886ac045119453",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -956,7 +956,7 @@
"ext-json": "*", "ext-json": "*",
"topthink/framework": "^6.0" "topthink/framework": "^6.0"
}, },
"time": "2020-01-06T07:30:03+00:00", "time": "2020-01-06T07:42:55+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"think": { "think": {

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2020-01-06 15:31:56 // This file is automatically generated at:2020-01-06 15:45:08
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'think\\app\\Service', 0 => 'think\\app\\Service',

View File

@ -49,8 +49,7 @@ class ListenQueue extends Command
* @param Output $output 输出对象 * @param Output $output 输出对象
*/ */
protected function execute(Input $input, Output $output) protected function execute(Input $input, Output $output)
{ $this->output->writeln('进程'); {
$this->output->writeln(getmypid());
set_time_limit(0); set_time_limit(0);
$this->app->db->name('SystemQueue')->count(); $this->app->db->name('SystemQueue')->count();
if (($this->process = ProcessService::instance())->iswin()) { if (($this->process = ProcessService::instance())->iswin()) {
@ -86,8 +85,6 @@ class ListenQueue extends Command
*/ */
protected function update($code, array $data = []) protected function update($code, array $data = [])
{ {
return $this->app->db->name('SystemQueue')->where(['code' => $code])->update($data); return $this->app->db->name('SystemQueue')->where(['code' => $code])->update($data);
} }

View File

@ -73,8 +73,7 @@ class WorkQueue extends Command
} else { } else {
// 锁定任务状态 // 锁定任务状态
$this->app->db->name($this->table)->strict(false)->where(['code' => $this->code])->update([ $this->app->db->name($this->table)->strict(false)->where(['code' => $this->code])->update([
'status' => '2', 'enter_time' => microtime(true), 'outer_time' => '0', 'status' => '2', 'enter_time' => microtime(true), 'outer_time' => '0', 'exec_pid' => getmypid(), 'exec_desc' => '', 'attempts' => $this->app->db->raw('attempts+1'),
'exec_pid' => getmygid(), 'exec_desc' => '', 'attempts' => $this->app->db->raw('attempts+1'),
]); ]);
// 设置进程标题 // 设置进程标题
if (($process = ProcessService::instance())->iswin()) { if (($process = ProcessService::instance())->iswin()) {
@ -115,7 +114,7 @@ class WorkQueue extends Command
{ {
$desc = explode("\n", trim(is_string($message) ? $message : '')); $desc = explode("\n", trim(is_string($message) ? $message : ''));
$result = $this->app->db->name($this->table)->strict(false)->where(['code' => $this->code])->update([ $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 : ''); $this->output->writeln(is_string($message) ? $message : '');
return $result == false; return $result == false;