Documents injecute 1.x · Migrating from 0.x
Skip to content

Interface: RunningLifecycle ​

Defined in: src/utils/lifecycle.ts:229

A started lifecycle, returned by startLifecycle.

Example ​

ts
const running = await startLifecycle(app);
console.log('started', running.hooks);
process.once('SIGTERM', () => running.stop().catch((error) => logger.error(error)));

// in a test: stopped at the end of the block
await using test = await startLifecycle(app.fork({ isolated: true }));

Properties ​

hooks ​

readonly hooks: readonly ServiceKey[]

Defined in: src/utils/lifecycle.ts:233

The hook keys that ran, in the order they were started (for startup logs and tests).


state ​

readonly state: LifecycleState

Defined in: src/utils/lifecycle.ts:231

started, then stopping and stopped once stop() is called.

Methods ​

[asyncDispose]() ​

[asyncDispose](): Promise<void>

Defined in: src/utils/lifecycle.ts:242

Same as stop(); enables await using running = await startLifecycle(app).

Returns ​

Promise<void>


stop() ​

stop(options?): Promise<void>

Defined in: src/utils/lifecycle.ts:240

Runs the undo functions in reverse order (stage by stage, the last stage first), then disposes the container (unless dispose: false). Returns the same promise when called again. Rejects with INJECUTE_DISPOSE_FAILED when some of them failed (each undo failure is an INJECUTE_UNDO_FAILED in cause.errors, with the hook's key in path); the others still ran.

Parameters ​

options? ​

StopLifecycleOptions

Returns ​

Promise<void>

Released under the MIT License.