4.2 Service Registry

At run time, shepherd maintains a service registry that maps service names to service records. Service dependencies are expressed as a list of names passed as #:requirement to the service procedure (see Defining Services); these names are looked up in the registry. Likewise, when running herd start sshd or similar commands (see Jump Start), the service name is looked up in the registry.

Consequently, every service must be appear in the registry before it can be used. A typical configuration file thus includes a call to the register-services procedure (see Service Examples). The following procedures let you interact with the registry.

Procedure: register-services services

Register services so that they can be looked up by name, for instance when resolving dependencies.

Each name uniquely identifies one service. If a service with a given name has already been registered, arrange to have it replaced when it is next stopped. If it is currently stopped, replace it immediately.

Procedure: unregister-services services

Remove all of services from the registry, stopping them if they are not already stopped.

Procedure: lookup-service name

Return the service that provides name, #f if there is none.

Procedure: for-each-service proc

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

Procedure: lookup-running name

Return the running service that provides name, or false if none.