fix(07): CR-02 correct cron expression for pollIntervalMin >= 60
Values >=60 in the cron minute field silently misbehave (*/60 fires once per hour, */90 fires once per hour, etc.). Use the hours field for intervals >=60: <60 min → */N * * * * >=60 min → 0 */H * * * (H = floor(N/60)) Also adds @Max(1440) to DkvConfigDto to bound the field at 24 h.
This commit is contained in:
@@ -101,8 +101,15 @@ export class DkvSchedulerService implements OnModuleInit {
|
||||
/* Job not yet registered — this is expected on first call */
|
||||
}
|
||||
|
||||
// Create new cron job with computed expression: every N minutes
|
||||
const cronExpr = `*/${intervalMin} * * * *`;
|
||||
// Create new cron job with computed expression.
|
||||
// Standard cron minute field only accepts 0–59; for longer intervals use the hours field.
|
||||
let cronExpr: string;
|
||||
if (intervalMin < 60) {
|
||||
cronExpr = `*/${intervalMin} * * * *`; // e.g. */15 * * * *
|
||||
} else {
|
||||
const hours = Math.floor(intervalMin / 60);
|
||||
cronExpr = `0 */${hours} * * *`; // e.g. 0 */2 * * *
|
||||
}
|
||||
const job = new CronJobClass(cronExpr, () => {
|
||||
this.dkvService.processInbox(tenant).catch((err) =>
|
||||
this.logger.error(
|
||||
|
||||
Reference in New Issue
Block a user