MCPcopy
hub / github.com/adonisjs/core / start

Method start

src/ignitor/http.ts:152–202  ·  view source on GitHub ↗

* Start the HTTP server by wiring up the application * * @param serverCallback - Optional callback to create custom HTTP server instance

(
    serverCallback?: (
      handler: (req: IncomingMessage, res: ServerResponse) => any
    ) => NodeHttpsServer | NodeHttpServer
  )

Source from the content-addressed store, hash-verified

150 * @param serverCallback - Optional callback to create custom HTTP server instance
151 */
152 async start(
153 serverCallback?: (
154 handler: (req: IncomingMessage, res: ServerResponse) => any
155 ) => NodeHttpsServer | NodeHttpServer
156 ) {
157 const startTime = process.hrtime()
158
159 /**
160 * Method to create the HTTP server
161 */
162 const createHTTPServer = serverCallback || createServer
163 const app = this.#ignitor.createApp('web')
164
165 await app.init()
166 await app.boot()
167 await app.start(async () => {
168 /**
169 * Resolve and boot the AdonisJS HTTP server
170 */
171 const server = await app.container.make('server')
172 await server.boot()
173
174 /**
175 * Create Node.js HTTP server instance and share it with the
176 * AdonisJS HTTP server
177 */
178 const httpServer = createHTTPServer(server.handle.bind(server))
179 server.setNodeServer(httpServer)
180
181 const logger = await app.container.make('logger')
182 const emitter = await app.container.make('emitter')
183
184 /**
185 * Start the server by listening on a port of host
186 */
187 const payload = await this.#listen(httpServer)
188
189 /**
190 * Notify
191 */
192 this.#notifyServerHasStarted(app, logger, emitter, {
193 ...payload,
194 duration: process.hrtime(startTime),
195 })
196
197 /**
198 * Monitor app and the server (after the server is listening)
199 */
200 this.#monitorAppAndServer(httpServer, app, logger)
201 })
202 }
203}

Callers 8

installPackagesMethod · 0.45
runMethod · 0.45
runMethod · 0.45
runMethod · 0.45
handleMethod · 0.45
providers.spec.tsFile · 0.45
http.spec.tsFile · 0.45

Calls 6

#listenMethod · 0.95
#monitorAppAndServerMethod · 0.95
createAppMethod · 0.80
makeMethod · 0.80
bootMethod · 0.45

Tested by

no test coverage detected