Ir al contenido
Español

CoordinatedStartup

Esta página aún no está disponible en tu idioma.

Defined in: src/CoordinatedStartup.ts:111

The system’s startup, run as a graph of phases — the counterpart of CoordinatedShutdown at the other end of a system’s life (#1473).

The framework runs it, so no main has to remember to. The tasks come in through ActorSystemOptions.withCoordinatedStartup, and the system starts the graph as the last step of ActorSystem.create: tasks of one phase run concurrently, phases in dependency order, and whenReady — also on the system — settles once the last phase has. A step that has to happen after a plugin is registered and before the node takes traffic is a task in a phase, not a call every application has to place correctly.

Two phases are seeded, persistence-start and then before-system-ready, and neither recovers: a task that fails, or outlives its phase’s budget, stops the run, rejects whenReady() with an error naming the phase and the task, and takes the system down through the coordinated-shutdown pipeline with a StartupFailedReason. runUntilTerminated() then ends with that error, so a process whose startup failed exits by itself, non-zero. A declared phase with recover: true logs a failure and carries on instead. While the graph runs, the startup readiness check of healthChecksOf(system) keeps /ready false.

A shutdown overtakes it. A system that begins shutting down while the graph runs abandons the startup rather than failing it: the running tasks’ signals abort, no further phase starts, whenReady() rejects with an abandonment error, and nothing is logged above debug, so a SIGTERM during startup ends the process as a shutdown. It happens before the pipeline’s first phase, whatever started it: terminate() abandons before it starts its pipeline, and every coordinated-shutdown run — a signal’s, an explicit run() — does as it begins.

The budgets are the deployment’s to tune. actor-ts.coordinated-startup carries the default phase budget and a phases block of the shutdown block’s shape, both under what the options set in code: a phase an option entry names is that entry’s, the block’s children retime or declare the rest, and a task may run in a phase only the block declares.

The graph is sealed when create returns. A task added afterwards would never run — the phases it belongs to may be over — so addTask and addPhase refuse from then on, naming the option that works.

new CoordinatedStartup(system, options?): CoordinatedStartup

Defined in: src/CoordinatedStartup.ts:128

ActorSystem

CoordinatedStartupOptions = {}

CoordinatedStartup

get failure(): Error | undefined

Defined in: src/CoordinatedStartup.ts:215

The error whenReady rejected with because a task failed, or undefined — also after an abandonment, which is not a failure.

Error | undefined


get hasTasks(): boolean

Defined in: src/CoordinatedStartup.ts:197

Whether any phase has a task. A graph without one is complete the moment it starts.

boolean


get isComplete(): boolean

Defined in: src/CoordinatedStartup.ts:206

True once every phase has run without a failure that stopped the run.

boolean


get isRunning(): boolean

Defined in: src/CoordinatedStartup.ts:203

True while the graph runs: from the end of create until its last phase, a failure or an abandonment.

boolean


get runningPhase(): string | undefined

Defined in: src/CoordinatedStartup.ts:209

The phase running now, or undefined when none is.

string | undefined

addPhase(definition): void

Defined in: src/CoordinatedStartup.ts:172

Add a phase — refused once the system is constructed, like addTask.

PhaseDefinition

void


addTask(phase, name, task): void

Defined in: src/CoordinatedStartup.ts:166

Register a task — refused once the system is constructed, which is always the case by the time application code holds the extension. Pass startup work through ActorSystemOptions.withCoordinatedStartup instead.

string

string

StartupTask

void


phaseDefinition(phase): PhaseDefinition | undefined

Defined in: src/CoordinatedStartup.ts:192

The resolved definition of a phase — after the options retimed or added it — or undefined.

string

PhaseDefinition | undefined


whenReady(): Promise<void>

Defined in: src/CoordinatedStartup.ts:223

Resolves once every phase has run; rejects with the error that stopped the run, or with an abandonment error when the system was terminated first. The same promise every call, and already resolved for a graph without tasks — no timer is armed for one.

Promise<void>