Updated A LOT
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
const { createApp } = require('./app');
|
||||
const { runAlertCycle } = require('./services/alerts');
|
||||
const { runScheduledSync } = require('./services/workday');
|
||||
|
||||
const PORT = Number(process.env.PORT || process.env.MIXEDASSETS_PORT || 3000);
|
||||
const app = createApp();
|
||||
@@ -6,3 +8,21 @@ const app = createApp();
|
||||
app.listen(PORT, () => {
|
||||
console.log(`MixedAssets API listening on http://localhost:${PORT}`);
|
||||
});
|
||||
|
||||
// Periodically scan for due/expiring items and email digests. These are no-ops
|
||||
// unless alerts are enabled and SMTP is configured. Runs after boot, then twice daily.
|
||||
function scheduleAlertCycle() {
|
||||
const tick = () => runAlertCycle(null).catch((error) => console.error('Alert cycle failed:', error.message));
|
||||
setTimeout(tick, 30_000).unref();
|
||||
setInterval(tick, 12 * 60 * 60 * 1000).unref();
|
||||
}
|
||||
|
||||
// Hourly check for a due automatic Workday sync (respects the configured interval).
|
||||
function scheduleWorkdaySync() {
|
||||
const tick = () => runScheduledSync().catch((error) => console.error('Workday sync failed:', error.message));
|
||||
setTimeout(tick, 60_000).unref();
|
||||
setInterval(tick, 60 * 60 * 1000).unref();
|
||||
}
|
||||
|
||||
scheduleAlertCycle();
|
||||
scheduleWorkdaySync();
|
||||
|
||||
Reference in New Issue
Block a user