Files
worldmonitor/scripts/process-simulation-tasks.mjs
Elie Habib 4985bb4978 fix(workers): always log startup and exit reason (#2717)
Deep-forecast and simulation workers exited silently on idle, making
it impossible to distinguish "no tasks" from "crashed on import" in
Railway logs. Now logs Starting/Exiting with status on every run,
and FATAL with error message on uncaught exceptions.
2026-04-05 09:03:34 +04:00

19 lines
606 B
JavaScript

#!/usr/bin/env node
import { loadEnvFile } from './_seed-utils.mjs';
import { runSimulationWorker } from './seed-forecasts.mjs';
loadEnvFile(import.meta.url);
const once = process.argv.includes('--once');
const runId = process.argv.find((arg) => arg.startsWith('--run-id='))?.split('=')[1] || '';
try {
console.log(`[Simulation] Starting (once=${once}, pid=${process.pid})`);
const result = await runSimulationWorker({ once, runId });
console.log(`[Simulation] Exiting: ${result?.status || 'unknown'}`);
} catch (err) {
console.error(`[Simulation] FATAL: ${err.message}`);
process.exit(1);
}