4.3 Service Convenience

In addition to the facilities listed below, there are also some procedures that provide commonly needed constructors and destructors for services Service De- and Constructors.

procedure: register-services . services

Register all services, so that they can be taken into account when trying to resolve dependencies.

procedure: lookup-services name

Return a list of all registered services which provide the symbol name.

macro: make-actions (name proc) ...

This macro is used to create a value for the actions slot of a service object Slots of services. Each name is a symbol and each proc the corresponding procedure that will be called to perform the action. A proc has one argument, which will be the current value of the running slot of the service.

method: start (obj <symbol>)

Start a registered service providing obj.

procedure: start-in-the-background services

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 herd command.

method: stop (obj <symbol>)

Stop a registered service providing obj.

method: action (obj <symbol>) the-action . args

The same as the action method of class <service>, but uses a service that provides obj and is running.

procedure: for-each-service proc

Call proc, a procedure taking one argument, once for each registered service.

procedure: find-running services

Check if any of services is running. If this is the case, return its canonical name. If not, return #f. Only the first one will be returned; this is because this is mainly intended to be applied on the return value of lookup-services.