Skip to content

Documentation for declaring service dependencies seems to contradict itself #28

@pascal-fb-martin

Description

@pascal-fb-martin

I am going through the runit documentation, starting with the Q&A:

How do I make a service depend on another service
I have a service that needs another service to be available before it can start. How can I tell runit about this dependency?
Answer: Make sure in the ./run script of the dependant service that the service it depends on is available before the service daemon starts. The sv program can be used for that. E.g. the cron service wants the socklog-unix system logging service to be available before starting the cron service daemon, so no logs get lost:

$ cat /etc/sv/cron/run
#!/bin/sh
sv start socklog-unix || exit 1
exec cron -f
$
See also the documentation.

Following the "documentation" link above leads to this less clear description:

runit's service supervision resolves dependencies for service daemons designed to be run by a supervisor process automatically. The service daemon (or the corresponding run scripts) should behave as follows:
before providing the service, check if all services it depends on are available. If not, exit with an error, the supervisor will then try again.
write all logs through runit's logging facility. The runsv program takes care that all logs for the service are written safely to disk. Therefore there's no need to depend on a system logging service.
optionally when the service is told to become down, take down other services that depend on this one after disabling the service.
If you want to run service daemons that do not support service supervision as described above, please refer to this page about service dependencies I wrote some time ago.

I am not sure what "do not support service supervision" means. The service I depend on is also started through runit.

Following the this page link above leads to a third seemingly conflicting description:

Service dependency
If you really have a service that needs another service up and running before starting, you can use the svwaitup program included in the runit package.
Add a line like this to the service's run script:

#!/bin/sh
svwaitup 3 /service/tinydns /service/dnscache || exit 1
exec /example/service/startup
This will cause this service to start as soon as /service/tinydns and /service/dnscache were at least 3 seconds up and running.
For each service it depends on, add the corresponding service directory to the arguments of svwaitup.

Note that there is always a race condition, the service it depends on could die just in the moment it was 3 seconds up.

The svwaitup is nowhere to be found on a newly installed Void Linux (using void-live-x86_64-20230628-base.iso).

Which of these three pages should I believe?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions