compose.up
compose.up
is the primary function used to initialize list of containers, ensuring they are set up in the correct order based on their dependencies. This function manages the execution flow and provides optional debugging output.
Syntax
Parameters
- containers (
Container[]
): An array of containers to initialize. Each container in the array is processed based on its dependencies (dependsOn
andoptionalDependsOn
), regardless of the order in which it appears. - config (optional,
{ debug?: boolean }
): An optional configuration object with the following property:- debug (
boolean
): Iftrue
,compose.up
will output detailed status updates to the console each time a container’s status changes. This is useful for tracking initialization and troubleshooting dependency issues.
- debug (
Return Value
compose.up
returns a promise that resolves to an object with the following structure:
- hasErrors (
boolean
): Indicates whether any container encountered an error during initialization. - statuses (
Record<Container['id'], Container['status']>
): An object that maps each container ID to its final status (idle
,pending
,done
,fail
, oroff
).
Example
Expected Resolution Order
Notes
compose.up
automatically handles dependencies based on the configuration of each container.- The function only begins each container when its required dependencies are fully initialized (
done
status).