ThatGuyB's rants

In technical terms, I see that example as a viable option. However, in practical terms, I don’t see any reason why you’d want to use a program with networking capabilities under normal circumstances, without having network enabled.

Postgres comes to mind immediately. You can connect on either unix socket or tcp socket. If your software stack only uses pg locally and nothing accesses the DB from the network, just don’t do a dependency on networking, only connect on local socket. If you do need PG to be accessed on the LAN for normal operations, you do a hard dependency on the networking service.

Your software stack can either be local / confined, or be a network resource, but I don’t see any scenario where you’d want to define a “nice to have, but not mandatory” dependency. And again, this can be handled by the service itself, if really needed and doesn’t need to be implemented in the service manager.

This is the execline version I just came up with: if -n { eltest -f /run/service/networking/down } { pg_ctl -D /path/to/pg/db start }. It means “if the down file doesn’t exist for networking (denoting it was started, but doesn’t check if the networking service is up or not), start postgres.”

The “-n” is negating the test and implicitly in execline if the “if” fails, it’ll exit with code 128 + the exit code of the command inside the if block (eltest’s exit code). So if eltest exists 1, the if will exit 129 and the pg service won’t be started.

s6-svscan then reattempts to start the service, once it failed. So the admin must ensure networking is enabled (in systemd terms), not that it’s running / up, to start your service (I believe this is true for systemd too, if a service is not enabled, then you have to start it manually for others to kick off after them, right? please correct me if I’m wrong, I didn’t read into this behavior). In the s6-rc case, this will just go on for the defined number of retries (which can be infinite) until the networking service is started (again, the networking itself can be in a failed state, but the service “networking” is started).

s6-rc works this way: if a service has a dependency (which in s6 is always a hard dependency) and it’s set to start up (either at boot or manually), it will always first start its parent dependencies and if these cannot start, the service will never start (if you have a service that can only be launched if you have networking running, then you shouldn’t try to start it without networking).


Back to my question on systemd, where you can correct me, to add a bit more detail. If you have a custom service “rsync” that is enabled and has a dependency (either After= or Requires= or both) on sshd, but sshd is disabled, will systemd try to start “sshd” service because the “rsync” service is enabled, or will the service stay down indefinitely because sshd is not enabled?