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

Method _start

lib/core.js:259–308  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

257 }
258
259 async _start() {
260
261 if (this.phase === 'initialized' ||
262 this.phase === 'started') {
263
264 this._validateDeps();
265 }
266
267 if (this.phase === 'started') {
268 return;
269 }
270
271 if (this.phase !== 'stopped' &&
272 this.phase !== 'initialized') {
273
274 throw new Error('Cannot start server while it is in ' + this.phase + ' phase');
275 }
276
277 if (this.phase !== 'initialized') {
278 await this._initialize();
279 }
280
281 this.phase = 'starting';
282 this.started = true;
283 this.info.started = Date.now();
284
285 try {
286 await this._listen();
287 }
288 catch (err) {
289 this.started = false;
290 this.phase = 'invalid';
291 throw err;
292 }
293
294 this.phase = 'started';
295 this.events.emit('start');
296
297 try {
298 if (this.controlled) {
299 await Promise.all(this.controlled.map((control) => control.start()));
300 }
301
302 await this._invoke('onPostStart');
303 }
304 catch (err) {
305 this.phase = 'invalid';
306 throw err;
307 }
308 }
309
310 _listen() {
311

Callers 1

startMethod · 0.80

Calls 6

_validateDepsMethod · 0.80
_initializeMethod · 0.80
emitMethod · 0.80
startMethod · 0.80
_listenMethod · 0.45
_invokeMethod · 0.45

Tested by

no test coverage detected