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

Interface: StartLifecycleOptions<S> ​

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

Options of startLifecycle.

Example ​

ts
const running = await startLifecycle(app, {
  lifecycle: stages, // createLifecycle(['migrate', 'init', 'start'])
  concurrent: ['init'],
  signal: AbortSignal.timeout(30_000),
  onError: (error) => logger.warn(error),
});

Type Parameters ​

S ​

S extends string

Properties ​

concurrent? ​

optional concurrent?: boolean | readonly [S][S extends any ? 0 : never][]

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

Stages whose hooks run concurrently, or true for every stage. Default: false (one by one).


dispose? ​

optional dispose?: boolean

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

Dispose the container after running.stop() and after a failed start. Default: true. Pass false when something else disposes the container.


lifecycle? ​

optional lifecycle?: Lifecycle<S>

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

The stages to run, made by createLifecycle. Default: lifecycle (init, start, ready).


onError? ​

optional onError?: (error, context) => void

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

Receives the failures of a failed start that come after the first one (which startLifecycle() rejects with). Without it, they are dropped.

Parameters ​

error ​

unknown

context ​

LifecycleErrorContext

Returns ​

void


onHook? ​

optional onHook?: (event) => void

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

Called after each hook runs and after each undo function, with the time it took: for startup logs, metrics and finding slow hooks.

Parameters ​

event ​

LifecycleHookEvent

Returns ​

void


signal? ​

optional signal?: AbortSignalLike

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

Aborts a start that takes too long: the runner stops waiting for the pending hooks, undoes what ran (its undo functions receive the aborted signal and are waited for), disposes and rejects. A hook that finishes later is undone when it does; while it runs, disposing continues in the background.

Released under the MIT License.