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
|
turn depend on the
|
||||||
.Sy local
|
.Sy local
|
||||||
daemon).
|
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
|
Local system daemons should be started by overriding the
|
||||||
.Sy local
|
.Sy local
|
||||||
daemon in
|
daemon in
|
||||||
.Pa /etc/init/local ,
|
.Pa /etc/init/local ,
|
||||||
which then depends on the locally required daemons.
|
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: Daemon model.
|
||||||
.\" TODO: Log files.
|
.\" TODO: Log files.
|
||||||
.\" TODO: Readyness.
|
.\" TODO: Readyness.
|
||||||
.\" TODO: chroot /var/empty
|
.\" TODO: chroot /var/empty
|
||||||
.\" TODO: Environment variables.
|
.\" 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: Run daemon as specific user.
|
||||||
.\" TODO: /etc/environment or /etc/environ.
|
.\" TODO: /etc/environment or /etc/environ.
|
||||||
.\" TODO: Environment variables.
|
.\" TODO: Environment variables.
|
||||||
|
@ -238,8 +254,8 @@ Any other exit means the daemon failed.
|
||||||
The
|
The
|
||||||
.Sy poweroff-reboot
|
.Sy poweroff-reboot
|
||||||
meaning is that exiting 0 means the system should power off, exiting 1 means the
|
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
|
system should reboot, exiting 2 means the system should halt, and any other exit
|
||||||
preferably be used if the system should panic).
|
means the daemon failed.
|
||||||
.Pp
|
.Pp
|
||||||
Daemons are considered successful if they exit by
|
Daemons are considered successful if they exit by
|
||||||
.Sy SIGTERM
|
.Sy SIGTERM
|
||||||
|
@ -267,12 +283,12 @@ log data.
|
||||||
Control messages are inserted as entries from the daemon
|
Control messages are inserted as entries from the daemon
|
||||||
.Sy init .
|
.Sy init .
|
||||||
.Pp
|
.Pp
|
||||||
The default is to include control messages.
|
The default is
|
||||||
.It Sy log-exec Ar program Oo Ar argument ... Oc
|
.Sy true
|
||||||
When using the
|
and is
|
||||||
.Sy pipe
|
inherited from the
|
||||||
log method, start the log process using this program and arguments.
|
.Sy default
|
||||||
.\" TODO: The name of the daemon should be inserted as an argument?
|
deamon.
|
||||||
.It Sy log-format Ar format
|
.It Sy log-format Ar format
|
||||||
Selects the
|
Selects the
|
||||||
.Ar format
|
.Ar format
|
||||||
|
@ -310,7 +326,10 @@ and the daemon name.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The default format is
|
The default format is
|
||||||
.Sy nanoseconds .
|
.Sy nanoseconds
|
||||||
|
and is inherited from the
|
||||||
|
.Sy default
|
||||||
|
deamon.
|
||||||
.It Sy log-line-size Ar line-size
|
.It Sy log-line-size Ar line-size
|
||||||
When using the
|
When using the
|
||||||
.Sy rotate
|
.Sy rotate
|
||||||
|
@ -318,8 +337,10 @@ log method, log files are cut at newlines if the lines don't exceed
|
||||||
.Ar line-size
|
.Ar line-size
|
||||||
bytes.
|
bytes.
|
||||||
.Pp
|
.Pp
|
||||||
The default value is 4096 bytes.
|
The default value is 4096 bytes and is inherited from the
|
||||||
.It Sy log-method Oo Sy none "|" append "|" rotate "|" pipe Oc
|
.Sy default
|
||||||
|
deamon.
|
||||||
|
.It Sy log-method Oo Sy none "|" append "|" rotate Oc
|
||||||
Selects the method for logging:
|
Selects the method for logging:
|
||||||
.Bl -tag -width "12345678"
|
.Bl -tag -width "12345678"
|
||||||
.It Sy none
|
.It Sy none
|
||||||
|
@ -327,7 +348,7 @@ Disable logging.
|
||||||
.It Sy append
|
.It Sy append
|
||||||
Always append the log data to the log file without any rotation.
|
Always append the log data to the log file without any rotation.
|
||||||
.Pp
|
.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.
|
exhausted.
|
||||||
.It Sy rotate
|
.It Sy rotate
|
||||||
Append lines to the log file until it becomes too large, in which case the
|
Append lines to the log file until it becomes too large, in which case the
|
||||||
|
@ -354,40 +375,25 @@ is begun.
|
||||||
.Pp
|
.Pp
|
||||||
This is the default log method.
|
This is the default log method.
|
||||||
This method will lose old log data.
|
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
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The default format is
|
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
|
.It Sy log-rotate-on-start Oo Sy false "|" true Oc
|
||||||
When starting the daemon, rotate the logs (when using the
|
When starting the daemon, rotate the logs (when using the
|
||||||
.Sy rotate
|
.Sy rotate
|
||||||
log method) or empty the log (when using the
|
log method) or empty the log (when using the
|
||||||
.Sy append
|
.Sy append
|
||||||
log method), such that the daemon starts out with a new log.
|
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
|
.It Sy log-size Ar size
|
||||||
When using the
|
When using the
|
||||||
.Sy rotate
|
.Sy rotate
|
||||||
|
@ -395,11 +401,15 @@ log method, keep each log file below
|
||||||
.Ar size
|
.Ar size
|
||||||
bytes.
|
bytes.
|
||||||
.Pp
|
.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
|
.It Sy need tty
|
||||||
.\" TODO: Only a single daemon can be this.
|
.\" TODO: Only a single daemon can be this.
|
||||||
Specifies that the daemon is not a background daemon, but instead a foreground
|
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.
|
.\" TODO: Make session leader.
|
||||||
The daemon is made a process group leader.
|
The daemon is made a process group leader.
|
||||||
The terminal's foreground process group is set to that of the daemon.
|
The terminal's foreground process group is set to that of the daemon.
|
||||||
|
@ -414,7 +424,7 @@ the
|
||||||
daemon readiness protocol.
|
daemon readiness protocol.
|
||||||
Upon exit, the original terminal settings are restored and
|
Upon exit, the original terminal settings are restored and
|
||||||
.Xr init 8
|
.Xr init 8
|
||||||
regains ownership of the terminal.
|
reclaims ownership of the terminal.
|
||||||
.It Sy per if
|
.It Sy per if
|
||||||
Specifies that an instance of the daemon should run for each network interface.
|
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
|
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
|
.Sy ( need tty
|
||||||
is set), then connect the daemon to the terminal named
|
is set), then connect the daemon to the terminal named
|
||||||
.Ar device .
|
.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 .
|
.Pa tty1 .
|
||||||
.El
|
.El
|
||||||
.Sh FILES
|
.Sh FILES
|
||||||
|
@ -564,6 +577,32 @@ require bard
|
||||||
require quxd
|
require quxd
|
||||||
exec exampled
|
exec exampled
|
||||||
.Ed
|
.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
|
.Ss Configuring a multi-user system
|
||||||
The system can be configured to boot into multi-user mode by creating
|
The system can be configured to boot into multi-user mode by creating
|
||||||
.Pa /etc/init/default
|
.Pa /etc/init/default
|
||||||
|
|
Loading…
Reference in New Issue