Skip to content

Commit

Permalink
feat: report duration of starting the web process via ignitor
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Nov 23, 2023
1 parent 2a029bb commit 4e10ffd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/ignitor/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class HttpServerProcess {
app: ApplicationService,
logger: LoggerService,
emitter: EmitterService,
payload: { host: string; port: number }
payload: { host: string; port: number; duration?: [number, number] }
) {
/**
* Notify parent process
Expand All @@ -123,6 +123,8 @@ export class HttpServerProcess {
handler: (req: IncomingMessage, res: ServerResponse) => any
) => NodeHttpsServer | NodeHttpServer
) {
const startTime = process.hrtime()

/**
* Method to create the HTTP server
*/
Expand Down Expand Up @@ -156,7 +158,10 @@ export class HttpServerProcess {
/**
* Notify
*/
this.#notifyServerHasStarted(app, logger, emitter, payload)
this.#notifyServerHasStarted(app, logger, emitter, {
...payload,
duration: process.hrtime(startTime),
})

/**
* Monitor app and the server (after the server is listening)
Expand Down
14 changes: 7 additions & 7 deletions tests/bindings/repl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
import { test } from '@japa/runner'

import is from '../../src/helpers/is.js'
import { Repl } from '../../modules/repl.js'
import stringHelpers from '../../src/helpers/string.js'
import { IgnitorFactory } from '../../factories/core/ignitor.js'
import AppServiceProvider from '../../providers/app_provider.js'
import ReplServiceProvider from '../../providers/repl_provider.js'

const BASE_URL = new URL('./tmp/', import.meta.url)

Expand All @@ -23,7 +21,11 @@ test.group('Bindings | Repl', () => {
const ignitor = new IgnitorFactory()
.merge({
rcFileContents: {
providers: ['../providers/app_provider.js', '../providers/hash_provider.js'],
providers: [
'../providers/app_provider.js',
'../providers/hash_provider.js',
'../providers/repl_provider.js',
],
},
})
.withCoreConfig()
Expand All @@ -42,18 +44,16 @@ test.group('Bindings | Repl', () => {
* Setting up REPL with fake server
* and context
*/
const repl = new Repl()
const repl = await app.container.make('repl')
repl.server = {
context: {},
displayPrompt() {},
} as any

app.container.singleton('repl', () => repl)

/**
* Define REPL bindings
*/
await new ReplServiceProvider(app).boot()
// await new ReplServiceProvider(app).boot()
const methods = repl.getMethods()

await methods.loadEncryption.handler(repl)
Expand Down
4 changes: 4 additions & 0 deletions tests/commands/eject.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ test.group('Eject', () => {
await command.exec()

assert.deepEqual(ace.ui.logger.getLogs(), [
{
message: '[ green(success) ] eject stubs/make/controller/actions.stub',
stream: 'stdout',
},
{
message: '[ green(success) ] eject stubs/make/controller/api.stub',
stream: 'stdout',
Expand Down

0 comments on commit 4e10ffd

Please sign in to comment.