Skip to content

Repository files navigation

initialization

A small init system and process supervisor. It runs as pid 1, brings a machine up from a directory of service scripts, keeps those services running, and reports what it is doing while it does it.

initialization is a fork of nitro by Leah Neukirchen. The supervision core is nitro's, and the license is nitro's. What is different here is the boot report, the naming, and the fact that it is the init system Arctic Linux ships rather than one of several a system might choose.

What it looks like

INIT is starting Arctic Linux

  :: Service 'udev'                              [  ok  ] t=0.3s
  :: Service 'network'                           [  ok  ] t=1.2s
  :: Service 'sshd'                              [  ok  ] t=0.1s

  Init done 1.9s

Every service reports how long it took to come up. On a slow boot that number is the whole diagnosis - it is the difference between "boot is slow" and "network takes eleven seconds" - and nothing else reports it. initctl list answers a different question: how long a service has been up.

The closing line appears once, when nothing is still on its way up. A service started later by hand does not reopen it.

Themes

Set INIT_THEME, or put the name in /etc/initialization/theme:

theme output
arctic the default: colour, aligned, timings
plain [ ok ] name (0.3s) - no escape sequences, for a serial console or a log
quiet service lines suppressed, the closing line kept
off nothing

plain is the one to use when the console is a pipe: the aligned output assumes a terminal that understands SGR, and a log file full of escape sequences is worse than no colour.

Services

A service is a directory under /etc/initialization containing a run script. It is run in the foreground - a service that daemonizes has nothing left to supervise, which is the usual reason a supervisor reports something as down that is plainly running.

/etc/initialization/
    sshd/
        run
        finish        optional, run when the service stops
    network/
        run
    getty@tty1/
        run           an instance; the text after @ is passed to run

A down file next to run means the service exists but is not started automatically. Directory names beginning with . are ignored, which is how a service is disabled without deleting it.

initctl

initctl list                 every service, its state and how long it has held it
initctl start <service>      start it now
initctl stop <service>       stop it, and leave it stopped
initctl restart <service>    stop, wait for it to be down, start
initctl check <service>      exit status says whether it is up
initctl scan                 re-read the service directory
initctl reboot               reboot the machine
initctl poweroff             power it off
initctl halt                 halt without powering off

On Arctic these are reached through service, which speaks to whichever init is running - the same command works under initialization, dinit, OpenRC and runit, so a service is started the same way whatever a machine was installed with.

Building

make

Builds with clang and lld and needs nothing else - no autotools, no configure, no libraries beyond libc. The result is two static-friendly binaries of about 40 KB.

make PREFIX=/usr DESTDIR=/tmp/stage install

Differences from nitro

  • The boot report above: per-service timing, alignment, themes, and a single closing line.
  • /etc/initialization as the service directory, initctl as the control tool, INIT_SOCK as the control socket variable.
  • poweroff, reboot and halt as initctl subcommands, so a machine can be brought down without a second tool.

Everything else - the supervision model, the state machine, the protocol - is nitro's, and bug reports about that behaviour belong upstream.

License

0BSD, as nitro is. See LICENSE.

About

A tiny init system and process supervisor with a boot report. Fork of nitro.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages