import { initPubnetTables, shouldAutoStartScheduler } from '../utils/db' import { pubnetScheduler } from '../utils/pubnet-scheduler' export default defineNitroPlugin(async (nitroApp) => { console.log('[Plugin] pubnet-init starting...') // DB 테이블 초기화 await initPubnetTables() // 스케줄러 자동 시작 (환경에 따라) if (shouldAutoStartScheduler()) { pubnetScheduler.start() console.log('[Plugin] pubnet scheduler auto-started (production mode)') } else { console.log('[Plugin] pubnet scheduler NOT started (development mode - use API to start)') } // 서버 종료 시 클린업 nitroApp.hooks.hook('close', () => { console.log('[Plugin] Shutting down pubnet scheduler...') pubnetScheduler.stop() }) console.log('[Plugin] pubnet-init completed') })