fixup! Add daemon support to init(8).
This commit is contained in:
parent
dbe049d4b8
commit
cb74742139
|
@ -38,17 +38,33 @@ which then depends on the daemons constituting the operating system (which in
|
|||
turn depend on the
|
||||
.Sy local
|
||||
daemon).
|
||||
The
|
||||
.Pa /etc/init/default
|
||||
file also defines default settings such as logging that are implicitly inherited
|
||||
by all other deamons, as well as
|
||||
.Xr init 8 Ns 's
|
||||
own
|
||||
.Pa /var/log/init.log
|
||||
file.
|
||||
.Pp
|
||||
Local system daemons should be started by overriding the
|
||||
.Sy local
|
||||
daemon in
|
||||
.Pa /etc/init/local ,
|
||||
which then depends on the locally required daemons.
|
||||
System provided daemons can be customized making
|
||||
.Pa /etc/init/exampled
|
||||
which starts with the
|
||||
.Sy furthermore
|
||||
statement to include the default
|
||||
.Pa /etc/share/exampled
|
||||
configuration and then change the desired properties.
|
||||
.\" TODO: Daemon model.
|
||||
.\" TODO: Log files.
|
||||
.\" TODO: Readyness.
|
||||
.\" TODO: chroot /var/empty
|
||||
.\" TODO: Environment variables.
|
||||
.\" TODO: No restart. exit 0 means finished. One stops.share/man/man5/init.5
|
||||
.\" TODO: No restart. exit 0 means finished. One stops.
|
||||
.\" TODO: Run daemon as specific user.
|
||||
.\" TODO: /etc/environment or /etc/environ.
|
||||
.\" TODO: Environment variables.
|
||||
|
@ -238,8 +254,8 @@ Any other exit means the daemon failed.
|
|||
The
|
||||
.Sy poweroff-reboot
|
||||
meaning is that exiting 0 means the system should power off, exiting 1 means the
|
||||
system should reboot, and any other exit means the daemon failed (exit 2 should
|
||||
preferably be used if the system should panic).
|
||||
system should reboot, exiting 2 means the system should halt, and any other exit
|
||||
means the daemon failed.
|
||||
.Pp
|
||||
Daemons are considered successful if they exit by
|
||||
.Sy SIGTERM
|
||||
|
@ -267,12 +283,12 @@ log data.
|
|||
Control messages are inserted as entries from the daemon
|
||||
.Sy init .
|
||||
.Pp
|
||||
The default is to include control messages.
|
||||
.It Sy log-exec Ar program Oo Ar argument ... Oc
|
||||
When using the
|
||||
.Sy pipe
|
||||
log method, start the log process using this program and arguments.
|
||||
.\" TODO: The name of the daemon should be inserted as an argument?
|
||||
The default is
|
||||
.Sy true
|
||||
and is
|
||||
inherited from the
|
||||
.Sy default
|
||||
deamon.
|
||||
.It Sy log-format Ar format
|
||||
Selects the
|
||||
.Ar format
|
||||
|
@ -310,7 +326,10 @@ and the daemon name.
|
|||
.El
|
||||
.Pp
|
||||
The default format is
|
||||
.Sy nanoseconds .
|
||||
.Sy nanoseconds
|
||||
and is inherited from the
|
||||
.Sy default
|
||||
deamon.
|
||||
.It Sy log-line-size Ar line-size
|
||||
When using the
|
||||
.Sy rotate
|
||||
|
@ -318,8 +337,10 @@ log method, log files are cut at newlines if the lines don't exceed
|
|||
.Ar line-size
|
||||
bytes.
|
||||
.Pp
|
||||
The default value is 4096 bytes.
|
||||
.It Sy log-method Oo Sy none "|" append "|" rotate "|" pipe Oc
|
||||
The default value is 4096 bytes and is inherited from the
|
||||
.Sy default
|
||||
deamon.
|
||||
.It Sy log-method Oo Sy none "|" append "|" rotate Oc
|
||||
Selects the method for logging:
|
||||
.Bl -tag -width "12345678"
|
||||
.It Sy none
|
||||
|
@ -327,7 +348,7 @@ Disable logging.
|
|||
.It Sy append
|
||||
Always append the log data to the log file without any rotation.
|
||||
.Pp
|
||||
This method does not lose log data but it will fail when disk space is
|
||||
This method does not lose log data but it will fail when filesystem space is
|
||||
exhausted.
|
||||
.It Sy rotate
|
||||
Append lines to the log file until it becomes too large, in which case the
|
||||
|
@ -354,40 +375,25 @@ is begun.
|
|||
.Pp
|
||||
This is the default log method.
|
||||
This method will lose old log data.
|
||||
.It Sy pipe
|
||||
The daemon's logs are piped to the standard input of its own log process running
|
||||
the
|
||||
.Sy log-exec
|
||||
program.
|
||||
.Pp
|
||||
After the daemon has stopped, the log daemon receives an end of file condition
|
||||
on its input.
|
||||
If the log daemon fails to exit after a timeout, it is sent
|
||||
.Sy SIGTERM.
|
||||
If it still hasn't exited after another timeout, it is killed with
|
||||
.Sy SIGKILL.
|
||||
.Pp
|
||||
The daemon will not start if the log process could not be started, and the
|
||||
daemon will stop with a failure if the log process fails.
|
||||
.\" TODO: This is harsh, a single log failure can bring down the system. The
|
||||
.\" log program needs to be written especially failsafe too. Maybe have a
|
||||
.\" mode that just loses log messages and tries again?
|
||||
.\" TODO: Have some sort of readiness signal in case the the process wants to
|
||||
.\" initialize buffers (e.g. connect) and not lose any messages if the log
|
||||
.\" fails?
|
||||
.Pp
|
||||
This method does not lose log data, always forwarding it to the spawned process,
|
||||
but the spawned process might of course lose it.
|
||||
.El
|
||||
.Pp
|
||||
The default format is
|
||||
.Sy rotate .
|
||||
.Sy rotate
|
||||
and is inherited from the
|
||||
.Sy default
|
||||
deamon.
|
||||
.It Sy log-rotate-on-start Oo Sy false "|" true Oc
|
||||
When starting the daemon, rotate the logs (when using the
|
||||
.Sy rotate
|
||||
log method) or empty the log (when using the
|
||||
.Sy append
|
||||
log method), such that the daemon starts out with a new log.
|
||||
.Pp
|
||||
The default value is
|
||||
.Sy false
|
||||
and is inherited from the
|
||||
.Sy default
|
||||
deamon.
|
||||
.It Sy log-size Ar size
|
||||
When using the
|
||||
.Sy rotate
|
||||
|
@ -395,11 +401,15 @@ log method, keep each log file below
|
|||
.Ar size
|
||||
bytes.
|
||||
.Pp
|
||||
The default value is 1048576 bytes.
|
||||
The default value is 1048576 bytes and is inherited from the
|
||||
.Sy default
|
||||
deamon.
|
||||
.It Sy need tty
|
||||
.\" TODO: Only a single daemon can be this.
|
||||
Specifies that the daemon is not a background daemon, but instead a foreground
|
||||
daemon that requires a terminal.
|
||||
daemon that requires the terminal in the
|
||||
.Sy tty
|
||||
property.
|
||||
.\" TODO: Make session leader.
|
||||
The daemon is made a process group leader.
|
||||
The terminal's foreground process group is set to that of the daemon.
|
||||
|
@ -414,7 +424,7 @@ the
|
|||
daemon readiness protocol.
|
||||
Upon exit, the original terminal settings are restored and
|
||||
.Xr init 8
|
||||
regains ownership of the terminal.
|
||||
reclaims ownership of the terminal.
|
||||
.It Sy per if
|
||||
Specifies that an instance of the daemon should run for each network interface.
|
||||
The daemon becomes a virtual daemon that depends on on the instantiated daemons
|
||||
|
@ -489,7 +499,10 @@ If the daemon is a foreground daemon
|
|||
.Sy ( need tty
|
||||
is set), then connect the daemon to the terminal named
|
||||
.Ar device .
|
||||
This property is currently ignored and the daemon is always connected to
|
||||
.Pp
|
||||
The default value is the terminal
|
||||
.Xr init 8
|
||||
is attached to, usually
|
||||
.Pa tty1 .
|
||||
.El
|
||||
.Sh FILES
|
||||
|
@ -564,6 +577,32 @@ require bard
|
|||
require quxd
|
||||
exec exampled
|
||||
.Ed
|
||||
.Ss Changing the log format
|
||||
The default log format of daemons and
|
||||
.Xr init 8 Ns 's
|
||||
own can be set by setting the properties in
|
||||
.Pa /etc/init/default .
|
||||
A few examples:
|
||||
.Bd -literal
|
||||
log-format full
|
||||
log-method append
|
||||
.Ed
|
||||
.Pp
|
||||
Uses the
|
||||
.Sy full
|
||||
log format and grows the log without limit, never losing data unless the
|
||||
filesystem space is exhausted.
|
||||
.Bd -literal
|
||||
log-control-messages false
|
||||
log-format none
|
||||
log-method rotate
|
||||
log-rotate-on-start true
|
||||
.Ed
|
||||
.Pp
|
||||
Provides plain rotated log files, by disabling control messages from
|
||||
.Xr init 8
|
||||
about starting/stopping the daemon, turning off log metadata, and also rotates
|
||||
the log when the deamon is started.
|
||||
.Ss Configuring a multi-user system
|
||||
The system can be configured to boot into multi-user mode by creating
|
||||
.Pa /etc/init/default
|
||||
|
|
Loading…
Reference in New Issue