CoordinatedStartup
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
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.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CoordinatedStartup(
system,options?):CoordinatedStartup
Defined in: src/CoordinatedStartup.ts:128
Parameters
Section titled “Parameters”system
Section titled “system”options?
Section titled “options?”CoordinatedStartupOptions = {}
Returns
Section titled “Returns”CoordinatedStartup
Accessors
Section titled “Accessors”failure
Section titled “failure”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”Error | undefined
hasTasks
Section titled “hasTasks”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”boolean
isComplete
Section titled “isComplete”Get Signature
Section titled “Get Signature”get isComplete():
boolean
Defined in: src/CoordinatedStartup.ts:206
True once every phase has run without a failure that stopped the run.
Returns
Section titled “Returns”boolean
isRunning
Section titled “isRunning”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”boolean
runningPhase
Section titled “runningPhase”Get Signature
Section titled “Get Signature”get runningPhase():
string|undefined
Defined in: src/CoordinatedStartup.ts:209
The phase running now, or undefined when none is.
Returns
Section titled “Returns”string | undefined
Methods
Section titled “Methods”addPhase()
Section titled “addPhase()”addPhase(
definition):void
Defined in: src/CoordinatedStartup.ts:172
Add a phase — refused once the system is constructed, like addTask.
Parameters
Section titled “Parameters”definition
Section titled “definition”Returns
Section titled “Returns”void
addTask()
Section titled “addTask()”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.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”void
phaseDefinition()
Section titled “phaseDefinition()”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.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”PhaseDefinition | undefined
whenReady()
Section titled “whenReady()”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.
Returns
Section titled “Returns”Promise<void>
