All checks were successful
Build and Push Docker Image / build (push) Successful in 18s
Round open/close scheduling now runs as a 60s setInterval inside the app process (via instrumentation.ts register hook) instead of needing an external crontab. Removed the /api/cron/round-scheduler endpoint. - DRAFT rounds auto-activate when windowOpenAt arrives - ACTIVE rounds auto-close when windowCloseAt passes - Uses existing activateRound/closeRound from round-engine Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
/**
|
|
* Next.js Instrumentation — runs once on server startup.
|
|
* https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation
|
|
*/
|
|
export async function onRequestInit() {
|
|
// no-op — required export for instrumentation file
|
|
}
|
|
|
|
export async function register() {
|
|
// Only run on the Node.js server runtime (not edge, not build)
|
|
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
|
// Retroactive document analysis: analyze all files that haven't been analyzed yet.
|
|
// Runs in background on startup, non-blocking.
|
|
import('./server/services/document-analyzer')
|
|
.then(({ analyzeAllUnanalyzed }) => {
|
|
console.log('[Startup] Starting retroactive document analysis...')
|
|
analyzeAllUnanalyzed()
|
|
.then((result) => {
|
|
console.log(
|
|
`[Startup] Document analysis complete: ${result.analyzed} analyzed, ${result.skipped} skipped, ${result.failed} failed out of ${result.total} total`
|
|
)
|
|
})
|
|
.catch((err) => {
|
|
console.warn('[Startup] Document analysis failed:', err)
|
|
})
|
|
})
|
|
.catch(() => {})
|
|
|
|
// Round scheduler: check every 60s for rounds that need to open/close
|
|
import('./server/services/round-scheduler')
|
|
.then(({ processScheduledRounds }) => {
|
|
console.log('[Startup] Round scheduler started (60s interval)')
|
|
// Run once immediately, then every 60 seconds
|
|
processScheduledRounds().catch(() => {})
|
|
setInterval(() => {
|
|
processScheduledRounds().catch((err) => {
|
|
console.error('[RoundScheduler] Error:', err)
|
|
})
|
|
}, 60_000)
|
|
})
|
|
.catch(() => {})
|
|
}
|
|
}
|