From 12896659a8cbca676dab8c6b550f5bb61eda0ae7 Mon Sep 17 00:00:00 2001 From: whyour Date: Mon, 17 May 2021 10:44:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcron=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=98=BE=E7=A4=BA=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample/config.sample.sh | 4 +--- shell/task.sh | 2 +- shell/update.sh | 6 ++++-- src/pages/crontab/index.tsx | 13 ++++++++----- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/sample/config.sample.sh b/sample/config.sample.sh index 483e340f..dc30b081 100644 --- a/sample/config.sample.sh +++ b/sample/config.sample.sh @@ -17,9 +17,7 @@ CommandTimeoutTime="1h" MaxConcurrentNum="5" ## 在运行 task 命令时,随机延迟启动任务的最大延迟时间 -## 如果任务不是必须准点运行的任务,那么给它增加一个随机延迟,由你定义最大延迟时间,单位为秒,如 RandomDelay="300" ,表示任务将在 1-300 秒内随机延迟一个秒数,然后再运行 -## 在crontab.list中,在每小时第0-2分、第30-31分、第59分这几个时间内启动的任务,均算作必须准点运行的任务,在启动这些任务时,即使你定义了RandomDelay,也将准点运行,不启用随机延迟 -## 在crontab.list中,除掉每小时上述时间启动的任务外,其他任务在你定义了 RandomDelay 的情况下,一律启用随机延迟,但如果你给某些任务添加了 "now" 或者 "conc",那么这些任务也将无视随机延迟直接启动 +## 默认给javascript任务加随机延迟,如 RandomDelay="300" ,表示任务将在 1-300 秒内随机延迟一个秒数,然后再运行,取消延迟赋值为空 RandomDelay="300" ## 如果你自己会写shell脚本,并且希望在每次运行 ql update 命令时,额外运行你的 shell 脚本,请赋值为 "true",默认为true diff --git a/shell/task.sh b/shell/task.sh index 482488be..3c938606 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -78,7 +78,7 @@ usage() { define_cmd gen_array_scripts echo -e "task命令运行本程序自动添加进crontab的脚本,需要输入脚本的绝对路径或去掉 “$dir_scripts/” 目录后的相对路径(定时任务中请写作相对路径),用法为:" - echo -e "1.$cmd_task # 依次执行,如果设置了随机延迟并且当时时间不在0-2、30-31、59分内,将随机延迟一定秒数" + echo -e "1.$cmd_task # 依次执行,如果设置了随机延迟,将随机延迟一定秒数" echo -e "2.$cmd_task now # 依次执行,无论是否设置了随机延迟,均立即运行,前台会输出日志,同时记录在日志文件中" echo -e "3.$cmd_task conc # 并发执行,无论是否设置了随机延迟,均立即运行,前台不产生日志,直接记录在日志文件中" if [[ ${#array_scripts[*]} -gt 0 ]]; then diff --git a/shell/update.sh b/shell/update.sh index 01d4172d..cec93cc2 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -245,15 +245,17 @@ usage() { ## 更新qinglong update_qinglong() { echo -e "--------------------------------------------------------------\n" + [ -f $dir_root/package.json ] && ql_depend_old=$(cat $dir_root/package.json) git_pull_scripts $dir_root if [[ $exit_status -eq 0 ]]; then echo -e "\n更新$dir_root成功...\n" - npm_install_2 $dir_root - cp -f $file_config_sample $dir_config/config.sample.sh detect_config_version update_depend + + [ -f $dir_root/package.json ] && ql_depend_new=$(cat $dir_root/package.json) + [[ "$ql_depend_old" != "$ql_depend_new" ]] && npm_install_2 $dir_root else echo -e "\n更新$dir_root失败,请检查原因...\n" fi diff --git a/src/pages/crontab/index.tsx b/src/pages/crontab/index.tsx index 6b99912a..4263a981 100644 --- a/src/pages/crontab/index.tsx +++ b/src/pages/crontab/index.tsx @@ -103,7 +103,7 @@ const Crontab = () => { align: 'center' as const, render: (text: string, record: any) => ( <> - {!record.isDisabled && ( + {(!record.isDisabled || record.status !== CrontabStatus.idle) && ( <> {record.status === CrontabStatus.idle && ( } color="default"> @@ -125,7 +125,7 @@ const Crontab = () => { )} )} - {record.isDisabled === 1 && ( + {record.isDisabled === 1 && record.status === CrontabStatus.idle && ( } color="error"> 已禁用 @@ -194,9 +194,12 @@ const Crontab = () => { .get(`${config.apiPrefix}crons?searchValue=${searchText}`) .then((data: any) => { setValue( - data.data.sort( - (a: any, b: any) => CrontabSort[a.status] - CrontabSort[b.status], - ), + data.data.sort((a: any, b: any) => { + if (a.status === b.status && a.status === CrontabStatus.idle) { + return a.isDisabled - b.isDisable; + } + return CrontabSort[a.status] - CrontabSort[b.status]; + }), ); const runningTasks = data.data.filter( (x: any) => x.status !== CrontabStatus.idle,