From f863713f8f5eeb2193204ece229084b562255ce7 Mon Sep 17 00:00:00 2001 From: buqiyuan <1743369777@qq.com> Date: Sat, 17 Feb 2024 21:09:07 +0800 Subject: [PATCH] test --- .github/workflows/daily-curl-request.yml | 4 ++-- scripts/resetScheduler.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/daily-curl-request.yml b/.github/workflows/daily-curl-request.yml index 232e13fe..e3491505 100644 --- a/.github/workflows/daily-curl-request.yml +++ b/.github/workflows/daily-curl-request.yml @@ -2,7 +2,7 @@ name: Daily Curl Request on: schedule: - - cron: "*/12 * * * *" + - cron: "*/5 * * * *" jobs: run-curl: @@ -11,4 +11,4 @@ jobs: steps: - name: Run Curl Request # because: https://docs.render.com/free#spinning-down-on-idle - run: curl https://nest-admin-093x.onrender.com/api/auth/captcha/img \ No newline at end of file + run: curl https://nest-admin-093x.onrender.com \ No newline at end of file diff --git a/scripts/resetScheduler.ts b/scripts/resetScheduler.ts index 30213cc6..a9e98b19 100644 --- a/scripts/resetScheduler.ts +++ b/scripts/resetScheduler.ts @@ -5,7 +5,7 @@ import schedule from 'node-schedule' /** 此文件仅供演示时使用 */ const runMigrationGenerate = async function () { - exec('pnpm migration:revert && pnpm migration:run', (error, stdout, stderr) => { + exec('npm run migration:revert && npm run migration:run', (error, stdout, stderr) => { if (!error) console.log('操作成功', error) @@ -13,9 +13,13 @@ const runMigrationGenerate = async function () { console.log('操作失败', error) }) } +runMigrationGenerate() /** 每天凌晨 4.30 恢复初始数据 */ -schedule.scheduleJob('30 4 * * *', () => { +const job = schedule.scheduleJob('30 4 * * *', () => { runMigrationGenerate() console.log('Task executed daily at 4.30 AM:', new Date().toLocaleTimeString()) }) + +// 设置任务的执行时区 +job.setTimezone('Asia/Shanghai')