What we have seen so far is the interface to define a service and
to access it (see Defining Services). The procedures below, also
exported by the
(shepherd service) module, let you modify and
access the state of a service. You may use them in your configuration
file, for instance to start some or all of the services you defined
(see Service Examples).
Under the hood, each service record has an associated fiber (really: an actor) that encapsulates its state and serves user requests—a fiber is a lightweight execution thread (see Service Internals).
The procedures below let you change the state of a service.
Start service and its dependencies, passing args to its
start method. Return its running value,
#f on failure.
Stop service and any service that depends on it. Return the list of services that have been stopped (including transitive dependent services).
If service is not running, print a warning and return its canonical name in a list.
Perform the-action (a symbol such as
on service, passing it args. The meaning of args depends on
start-in-the-background procedure, described below, is
provided for your convenience: it makes it easy to start a set of
services right from your configuration file, while letting
shepherd run in the background.
Start the services named by services, a list of symbols, in the background. In other words, this procedure returns immediately without waiting until all of services have been started.
This procedure can be useful in a configuration file because it lets you
interact right away with shepherd using the
The following procedures let you query the current state of a service.
Return true if service is currently running/stopped/enabled, false otherwise.
Return the status of service as a symbol, one of:
Return the current “running value” of service—a Scheme value
associated with it. It is
#f when the service is stopped;
otherwise, it is a truth value, such as an integer denoting a PID
(see Service De- and Constructors).
Return the replacement of service, or
#f if there is
The replacement is the service that will replace service when it is eventually stopped.
See Service Internals, if you’re curious about the nitty-gritty details!