mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
+29
-12
@@ -14,8 +14,16 @@
|
||||
* That's the only wiring required — server.js never needs to
|
||||
* change when admin-side jobs are added/removed.
|
||||
*
|
||||
* taskOverdue is settings-backed (see cronRegistry.util.js) —
|
||||
* its schedule/enabled state lives in cron_notification_settings
|
||||
* and is configurable from /admin/notifications/settings without
|
||||
* a restart. liftExpiredBans is not notification-related, so it
|
||||
* stays on a plain hardcoded schedule.
|
||||
*
|
||||
* Currently registered:
|
||||
* - taskOverdue (cron/jobs/taskOverdue.cron.js)
|
||||
* - taskOverdue (cron/jobs/task_overdue.cron.js) — settings-backed
|
||||
* - liftExpiredBans (cron/jobs/lift_expired_bans.cron.js)
|
||||
* - dispatchEmailBroadcasts (cron/jobs/dispatch_email_broadcasts.cron.js)
|
||||
*
|
||||
* Author: Kenneth Obsequio (@lash0000)
|
||||
* Date Created: Jun. 17, 2026
|
||||
@@ -23,25 +31,34 @@
|
||||
const cron = require('node-cron');
|
||||
const taskOverdue = require('./jobs/task_overdue.cron');
|
||||
const liftExpiredBans = require('./jobs/lift_expired_bans.cron');
|
||||
const dispatchEmailBroadcasts = require('./jobs/dispatch_email_broadcasts.cron');
|
||||
const { startSettingsBackedJobs } = require('./cronRegistry.util');
|
||||
|
||||
// ─── Registry — add future admin-side cron jobs here ─────────────────────────
|
||||
const jobs = [
|
||||
const settingsBackedJobs = [
|
||||
taskOverdue,
|
||||
];
|
||||
|
||||
// Plain hardcoded-schedule jobs (not tied to any notification setting).
|
||||
const plainJobs = [
|
||||
liftExpiredBans,
|
||||
dispatchEmailBroadcasts,
|
||||
];
|
||||
|
||||
// ─── Boot all registered admin-side jobs ──────────────────────────────────────
|
||||
function startAdminCronJobs() {
|
||||
const registered = [];
|
||||
jobs.forEach(({ name, schedule, run }) => {
|
||||
if (!cron.validate(schedule)) {
|
||||
console.error(`[CRON][ADMIN] Invalid schedule for "${name}": "${schedule}" — skipped.`);
|
||||
return;
|
||||
async function startAdminCronJobs() {
|
||||
const registered = await startSettingsBackedJobs(settingsBackedJobs, 'ADMIN');
|
||||
|
||||
for (const job of plainJobs) {
|
||||
if (!cron.validate(job.schedule)) {
|
||||
console.error(`[CRON][ADMIN] Invalid schedule for "${job.name}": "${job.schedule}" — skipped.`);
|
||||
continue;
|
||||
}
|
||||
cron.schedule(schedule, run);
|
||||
registered.push({ name, scope: 'ADMIN', schedule });
|
||||
});
|
||||
cron.schedule(job.schedule, job.run);
|
||||
registered.push({ name: job.name, scope: 'ADMIN', schedule: job.schedule });
|
||||
}
|
||||
|
||||
return registered;
|
||||
}
|
||||
|
||||
module.exports = { startAdminCronJobs };
|
||||
module.exports = { startAdminCronJobs };
|
||||
|
||||
Reference in New Issue
Block a user