MCPcopy
hub / github.com/hapijs/hapi / _initialize

Method _initialize

lib/core.js:345–380  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

343 }
344
345 async _initialize() {
346
347 if (this.registring) {
348 throw new Error('Cannot start server before plugins finished registration');
349 }
350
351 if (this.phase === 'initialized') {
352 return;
353 }
354
355 if (this.phase !== 'stopped') {
356 throw new Error('Cannot initialize server while it is in ' + this.phase + ' phase');
357 }
358
359 this._validateDeps();
360 this.phase = 'initializing';
361
362 // Start cache
363
364 try {
365 const caches = [];
366 this.caches.forEach((cache) => caches.push(cache.client.start()));
367 await Promise.all(caches);
368 await this._invoke('onPreStart');
369 this.heavy.start();
370 this.phase = 'initialized';
371
372 if (this.controlled) {
373 await Promise.all(this.controlled.map((control) => control.initialize()));
374 }
375 }
376 catch (err) {
377 this.phase = 'invalid';
378 throw err;
379 }
380 }
381
382 _validateDeps() {
383

Callers 2

_startMethod · 0.80
initializeMethod · 0.80

Calls 4

_validateDepsMethod · 0.80
startMethod · 0.80
initializeMethod · 0.80
_invokeMethod · 0.45

Tested by

no test coverage detected