nitro —
a tiny but flexible init system and
process supervisior
nitro is a service supervisor that can be
used as a Unix init system.
Every directory inside dir (by default:
/etc/nitro) defines a service.
When used as init, and the argument dir is
‘S’ or ‘single’, nitro
looks at the directory /etc/nitro.single instead.
This can be used to boot into a special single-user mode.
Service directories must have a name shorter than 64 characters
and must not contain ‘,’ or newlines in the file name. Service
directories cannot be nested.
Service directories can contain the following files:
- setup
- If it exists, this script is run when starting the service, the service
enters state
SETUP. When
setup exits with status 111, the service enters
state FATAL. When setup
exits with state 0, the service progresses to state
STARTING. Else, setup is
restarted after a delay.
- run
- If it exists, this script should exec into the service. If this file does
not exist, the service is a
ONESHOT. When the
service does not exit for 2 seconds, it enters state
UP.
- log
- If this is a symlink to another service directory, the standard output of
the service is connected to the standard input of the target service using
a pipe.
- finish
- After the service has exited, this script is run with two arguments, the
exit status of the service and the signal if the service exited due to a
signal. Then, the service enters state
DOWN.
- down
- If this file exists, the service is not brought up automatically.
- down-signal
- If this file exists, the first character of it encodes the signal (see
nitroctl(1)) that is sent to the service to bring it down,
else SIGTERM.
NITRO_SOCK
- The control socket (by default:
/var/run/nitro/nitro.sock) where
nitro listens for commands sent by
nitroctl(1).
The following special files are used inside the service
directory:
- SYS/setup
- This script is run very early in boot, before all services are started. It
can already start services using
nitroctl(1).
- SYS/finish
- When system shutdown is requested, this script is run. When it exits, the
remaining services are brought down.
- SYS/reincarnate
- If this script exists,
nitro execs into it instead
of rebooting or shutting down.
- SYS/final
- This script is run after all services are stopped. When it exits, the root
file system is remounted read-only and the system shuts down/reboots.
nitro tries hard not to exit, being used
as pid 1.