-
Notifications
You must be signed in to change notification settings - Fork 232
Expand file tree
/
Copy pathinstrumentation.ts
More file actions
35 lines (30 loc) · 1.08 KB
/
instrumentation.ts
File metadata and controls
35 lines (30 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Next.js Instrumentation Hook
*
* This file is called once when the Next.js server starts.
* Perfect for initializing event listeners and background jobs.
*
* @see https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation
*/
import { logger as baseLogger } from '@/lib/logger'
const logger = baseLogger.child({ module: 'instrumentation' })
/**
* Register function runs once when the Next.js server starts
* This is the entry point for all application initialization
*/
export async function register() {
// Only run on the server side
if (process.env.NEXT_RUNTIME === 'nodejs') {
logger.info('🚀 Application initialization started')
try {
// Import and initialize events and jobs
const { initializeApp } = await import('@/lib/startup')
await initializeApp()
logger.info('✅ Application initialization completed')
} catch (error) {
logger.error(`❌ Application initialization failed: ${error}`)
// Don't throw error to prevent app from crashing
// Jobs will retry on next reconcile cycle
}
}
}