File tree Expand file tree Collapse file tree 1 file changed +2
-17
lines changed
Expand file tree Collapse file tree 1 file changed +2
-17
lines changed Original file line number Diff line number Diff line change 1- import { setInterval } from 'node:timers' ;
21import { removeJobsByUserId } from './storage/jobStorage.js' ;
32import { config } from '../utils.js' ;
43import { getUsers } from './storage/userStorage.js' ;
54import logger from './logger.js' ;
5+ import cron from 'node-cron' ;
66
77/**
88 * if we are running in demo environment, we have to cleanup the db files (specifically the jobs table)
99 */
1010export function cleanupDemoAtMidnight ( ) {
11- const now = new Date ( ) ;
12- const millisUntilMidnightUTC =
13- ( 24 - now . getUTCHours ( ) ) * 60 * 60 * 1000 -
14- now . getUTCMinutes ( ) * 60 * 1000 -
15- now . getUTCSeconds ( ) * 1000 -
16- now . getUTCMilliseconds ( ) ;
17-
18- cleanup ( ) ;
19- setTimeout ( ( ) => {
20- setInterval (
21- ( ) => {
22- cleanup ( ) ;
23- } ,
24- 24 * 60 * 60 * 1000 ,
25- ) ;
26- } , millisUntilMidnightUTC ) ;
11+ cron . schedule ( '0 0 * * *' , cleanup ) ;
2712}
2813
2914function cleanup ( ) {
You can’t perform that action at this time.
0 commit comments