23 lines
729 B
TypeScript
23 lines
729 B
TypeScript
import { shouldAutoStartScheduler } from '../utils/db'
|
|
import { pubnetScheduler } from '../utils/pubnet-scheduler'
|
|
|
|
export default defineNitroPlugin(async (nitroApp) => {
|
|
console.log('[Plugin] pubnet-init starting...')
|
|
|
|
// 스케줄러 자동 시작 (환경에 따라)
|
|
if (shouldAutoStartScheduler()) {
|
|
pubnetScheduler.start()
|
|
console.log('[Plugin] pubnet scheduler auto-started (production mode)')
|
|
} else {
|
|
console.log('[Plugin] pubnet scheduler NOT started (development mode)')
|
|
}
|
|
|
|
// 서버 종료 시 클린업
|
|
nitroApp.hooks.hook('close', () => {
|
|
console.log('[Plugin] Shutting down pubnet scheduler...')
|
|
pubnetScheduler.stop()
|
|
})
|
|
|
|
console.log('[Plugin] pubnet-init completed')
|
|
})
|