2025-12-11 10:40:55 +01:00
|
|
|
/*
|
2026-01-12 15:00:36 +01:00
|
|
|
* Copyright (c) 2026 by Christian Kellner.
|
2025-12-11 10:40:55 +01:00
|
|
|
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
|
|
|
|
|
*/
|
|
|
|
|
|
2025-09-22 09:57:50 +02:00
|
|
|
import cron from 'node-cron';
|
|
|
|
|
import runActiveChecker from '../listings/listingActiveService.js';
|
2026-01-29 09:46:23 +01:00
|
|
|
import logger from '../logger.js';
|
|
|
|
|
import { getSettings } from '../storage/settingsStorage.js';
|
2025-09-22 09:57:50 +02:00
|
|
|
|
|
|
|
|
async function runTask() {
|
|
|
|
|
await runActiveChecker();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function initActiveCheckerCron() {
|
2026-01-29 09:46:23 +01:00
|
|
|
const settings = await getSettings();
|
|
|
|
|
if (settings.demoMode) {
|
|
|
|
|
logger.info('Do not start listing active checker as we are in demo mode');
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-09-22 09:57:50 +02:00
|
|
|
//run directly on start
|
|
|
|
|
await runTask();
|
|
|
|
|
// then every day at 1 am
|
|
|
|
|
cron.schedule('0 1 * * *', runTask);
|
|
|
|
|
}
|