MCPcopy
hub / github.com/subquery/subql / bootstrap

Function bootstrap

packages/node/src/init.ts:29–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27notifyUpdates(pjson, logger);
28
29export 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}

Callers 1

main.tsFile · 0.85

Calls 6

getValidPortFunction · 0.90
exitWithErrorFunction · 0.90
initMethod · 0.65
getMethod · 0.65
getFinalizedHeaderMethod · 0.65
createMethod · 0.45

Tested by

no test coverage detected