/** * Imported FIRST by main.ts / cli.ts so that CI_SERVICE and .env values are set before * `@cancerindex/shared` creates the pino logger (module-level singleton). */ import { existsSync } from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const here = path.dirname(fileURLToPath(import.meta.url)); for (const candidate of [path.resolve(here, '../../.env'), path.resolve(process.cwd(), '.env')]) { if (!existsSync(candidate)) continue; try { process.loadEnvFile(candidate); } catch { /* ignore malformed files */ } } process.env.CI_SERVICE ??= 'worker'; export const DATABASE_URL = process.env.DATABASE_URL ?? 'postgres://localhost:5432/cancerindex'; export const WORKER_CONCURRENCY = Math.max(1, Number(process.env.WORKER_CONCURRENCY ?? 2) || 2); export const CI_MAX_RUN_MINUTES = Math.max(1, Number(process.env.CI_MAX_RUN_MINUTES ?? 45) || 45); export const PGBOSS_SCHEMA = 'pgboss'; /** Job names — must match apps/api/src/lib/queue.ts. */ export const JOBS = { connectorRun: 'connector.run', counters: 'maintenance.counters', rank: 'maintenance.rank', intel: 'maintenance.intel', healthProbe: 'health.probe', } as const; export type JobName = (typeof JOBS)[keyof typeof JOBS]; /** Daily maintenance (UTC): counters after the nightly connector windows, rankings after counters. */ export const SCHEDULES = { counters: '0 6 * * *', intel: '15 6 * * *', rank: '30 6 * * *', healthProbe: '15 * * * *', } as const;