diff --git a/src/task/worker.ts b/src/task/worker.ts index 78a551c..b7d0ed8 100644 --- a/src/task/worker.ts +++ b/src/task/worker.ts @@ -13,7 +13,7 @@ class TimeRecorder { endTime: number; duration: number; updateTime: number; - maxDuration: number = 60 * 1000; // 20s; + maxDuration: number = 30 * 1000; // 30s; constructor() { const now = Date.now(); this.startTime = now; @@ -36,11 +36,14 @@ class TimeRecorder { } getClampDuration() { const duration = Date.now() - this.updateTime; + const nextTime = clamp(this.maxDuration - duration, 0, this.maxDuration); + // console.log('getClampDuration', duration, this.maxDuration, 'nextTime', nextTime); + return { duration: duration, maxDuration: this.maxDuration, updateTime: this.updateTime, - nextTime: clamp(this.maxDuration - duration, 0, this.maxDuration), + nextTime: nextTime, }; } time() { @@ -59,8 +62,9 @@ export const worker = new Worker( async (job) => { const timer = new TimeRecorder(); const data = job.data; + if (data.path === 'task' && data.key === 'getUnread') { - console.log('====run time', dayjs().format('YYYY-MM-DD HH:mm:ss')); + console.log('====run time start', dayjs().format('YYYY-MM-DD HH:mm:ss')); timeRecorder.update(); } const res = await taskApp.call(data);