Capy-Bearer Documentation

service_start

lib call

Capy

function service_start(unit : string, props : as any = {}) bool

Description

service_start() records that the service should run and starts it. Calling it on a running service does nothing and returns true. The supervisor starts one worker process for the unit, builds its workspace, compiles the unit, and runs SERVICE:START with the given props. Until then service_status() reports starting.

The recorded state survives a Bearer restart: every service that should run is started again when Bearer comes up.

A service_send() also starts a stopped service, with empty start props. Use service_start() when the service needs arguments.

A true result does not prove that compilation or START succeeded. Starting is asynchronous. Calling start while the desired state is already running does not replace the recorded props, even during crash recovery.

Unit paths are relative to the calling unit, or site-root-relative when they start with /. Pass the unit path without :START.

Parameters

unit : the unit path of the service, such as /agents/pool.capy

props : start arguments, delivered to SERVICE:START as its props

Return Values

true when the desired running state was recorded; false when the unit does not exist

Errors

State-directory, lock, and state-file failures trap instead of returning false.

A start whose unit does not exist returns false. A worker that fails to compile its unit or to build its workspace exits, which the supervisor logs and counts as a crash. A SERVICE:START that traps is logged and the service keeps running with whatever START left behind.

Example

Capy

service_start("/agents/pool.capy", count: 4)

Example

Capy

if service_start("/agents/pool.capy", count: 4)
{
	print(service_status("/agents/pool.capy").state)
}