()
| 27 | notifyUpdates(pjson, logger); |
| 28 | |
| 29 | export async function bootstrap(): Promise<void> { |
| 30 | const port = await getValidPort(argv.port); |
| 31 | |
| 32 | try { |
| 33 | const app = await NestFactory.create(AppModule, { |
| 34 | logger: new NestLogger(!!argv.debug), |
| 35 | }); |
| 36 | await app.init(); |
| 37 | |
| 38 | const projectService: ProjectService = app.get('IProjectService'); |
| 39 | const fetchService = app.get(FetchService); |
| 40 | const runtimeService: RuntimeService = app.get('RuntimeService'); |
| 41 | const dictionaryService: SubstrateDictionaryService = |
| 42 | app.get(DictionaryService); |
| 43 | const blockchainService: IBlockchainService = app.get('IBlockchainService'); |
| 44 | |
| 45 | // Initialise async services, we do this here rather than in factories, so we can capture one off events |
| 46 | await projectService.init(); |
| 47 | |
| 48 | const startHeight = projectService.startHeight; |
| 49 | const { blockHeight: finalizedHeight } = |
| 50 | await blockchainService.getFinalizedHeader(); |
| 51 | await runtimeService.init(startHeight, finalizedHeight, dictionaryService); |
| 52 | await fetchService.init(startHeight); |
| 53 | |
| 54 | app.enableShutdownHooks(); |
| 55 | |
| 56 | await app.listen(port); |
| 57 | |
| 58 | logger.info(`Node started on port: ${port}`); |
| 59 | } catch (e) { |
| 60 | exitWithError(new Error(`Node failed to start`, { cause: e }), logger); |
| 61 | } |
| 62 | } |
no test coverage detected