diff --git a/back/loaders/initTask.ts b/back/loaders/initTask.ts index 7587acc6..fbbea692 100644 --- a/back/loaders/initTask.ts +++ b/back/loaders/initTask.ts @@ -21,6 +21,7 @@ export default async () => { name: '生成token', command: tokenCommand, }; + await scheduleService.cancelIntervalTask(cron); scheduleService.createIntervalTask(cron, { days: 28, }); @@ -28,12 +29,13 @@ export default async () => { // 运行删除日志任务 const data = await systemService.getLogRemoveFrequency(); if (data && data.info && data.info.frequency) { - const cron = { + const rmlogCron = { id: data.id, name: '删除日志', command: `ql rmlog ${data.info.frequency}`, }; - scheduleService.createIntervalTask(cron, { + await scheduleService.cancelIntervalTask(rmlogCron); + scheduleService.createIntervalTask(rmlogCron, { days: data.info.frequency, }); } diff --git a/back/services/schedule.ts b/back/services/schedule.ts index b8b91012..40abee81 100644 --- a/back/services/schedule.ts +++ b/back/services/schedule.ts @@ -5,8 +5,8 @@ import { ChildProcessWithoutNullStreams, exec, spawn } from 'child_process'; import { ToadScheduler, LongIntervalJob, - AsyncTask, SimpleIntervalSchedule, + Task, } from 'toad-scheduler'; import dayjs from 'dayjs'; @@ -154,12 +154,10 @@ export default class ScheduleService { name, command, ); - const task = new AsyncTask( + const task = new Task( name, - async () => { - return new Promise(async (resolve, reject) => { - await this.runTask(command, callbacks); - }); + () => { + this.runTask(command, callbacks); }, (err) => { this.logger.error( @@ -180,7 +178,7 @@ export default class ScheduleService { this.intervalSchedule.addIntervalJob(job); if (runImmediately) { - await this.runTask(command, callbacks); + this.runTask(command, callbacks); } } diff --git a/shell/check.sh b/shell/check.sh index 14edcd66..c2b513f6 100644 --- a/shell/check.sh +++ b/shell/check.sh @@ -96,7 +96,6 @@ start_public() { main() { echo -e "=====> 开始检测" npm i -g pnpm - pnpm add -g pm2 patch_version start_public copy_dep diff --git a/shell/otask.sh b/shell/otask.sh index 9a0d53c1..9472fc0a 100644 --- a/shell/otask.sh +++ b/shell/otask.sh @@ -173,7 +173,7 @@ run_concurrent() { local envs=$(eval echo "\$${env_param}") local array=($(echo $envs | sed 's/&/ /g')) - single_log_time=$(date "+%Y-%m-%d-%H-%M-%S.%N") + single_log_time=$(date "+%Y-%m-%d-%H-%M-%S.%3N") cd $dir_scripts local relative_path="${file_param%/*}" diff --git a/shell/share.sh b/shell/share.sh index 5d733a9e..ef404c55 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -413,9 +413,9 @@ format_log_time() { local time="$2" if [[ $is_macos -eq 1 ]]; then - echo $(date -j -f "$format" "$time" "+%Y-%m-%d-%H-%M-%S") + echo $(date -j -f "$format" "$time" "+%Y-%m-%d-%H-%M-%S-%3N") else - echo $(date -d "$time" "+%Y-%m-%d-%H-%M-%S") + echo $(date -d "$time" "+%Y-%m-%d-%H-%M-%S-%3N") fi } @@ -450,9 +450,7 @@ patch_version() { echo fi - if ! type ts-node &>/dev/null; then - pnpm add -g ts-node typescript tslib - fi + pnpm add -g pm2 ts-node typescript tslib git config --global pull.rebase false diff --git a/shell/update.sh b/shell/update.sh index 5f460a4c..061b3902 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -231,7 +231,7 @@ usage() { update_qinglong() { local mirror="github" local githubStatus=$(curl -s -m 2 -IL "https://github.com" | grep 200) - if [ "$githubStatus" == "" ]; then + if [[ ! -z $githubStatus ]]; then mirror="gitee" fi echo -e "使用 ${mirror} 源更新...\n"