Log service plumbing

Managed services logging

In daemontools, a "main" service could optionally have a similar "log" service associated with it, the output of the one fed into the input of the other. Successors to daemontools, such as daemontools-encore and runit, have proceeded in the direction of hardwiring a 1:1 relationship between a "main" service and a "log" service, to the extent of making the utility commands non-orthogonal for "log" services. This package takes the opposite tack.

The service manager supports a flexible logging mechanism, where services can be plumbed together. For every loaded service it creates a pipe, attaching the read end of the pipe to the service process's standard input. Other services can be plumbed to that service. The service manager attaches their standard outputs and standard errors to the write end of the pipe.

This mechanism does not hardwire in a difference between "log" and "main" services. All services are on an equal footing as far as the service manager itself is concerned. The client that instructs the service manager, service-dt-scanner or system-control, determines exactly how services are plumbed together.

service-dt-scanner for compatibility maintains the daemontools notion of a set of "main" services each of which may optionally have 1 dedicated "log" service, and plumbs the two together. system-control makes no such distinction, and simply follows the "log" symbolic link in each bundle directory. In theory one could set up lengthy pipelines of services, each with its standard output and standard error plumbed to the standard input of the next. In practice there are two common scenarios.

System manager and per-user manager logging

There is also logging for the system-wide service manager itself. The system manager starts a logging dæmon, an instance of cyclog, whose standard input is connected to the read end of a pipe, the write end of which is connected to the standard output/error of the system-wide service manager process. If a service is not plumbed to another service, then it inherits its standard output and standard error from the service manager, and its log output goes to that logging dæmon. However, that logging dæmon logs to a temporary filesystem (the log files being written to /run/system-manager/log) and has an intentionally small cap on the log file sizes. It is not suitable for general-purpose logging, and is intended to log just the output of the service manager itself, and perhaps the (fairly humdrum) outputs of cyclog logging dæmons. All other dæmons should, properly, be plumbed to a logging service.

Per-user managers similarly set up an instance of cyclog, whose standard input is connected to the read end of a pipe, the write end of which is connected to the standard output/error of the per-user service manager process. The same considerations of inherited standard output and error in spawned per-user services apply; with the per-user log files written to /run/user/$USER/per-user-manager/log.