wiki:Init

Init system (in progress)

(TBD) IPlinux init system is based on runit.

System initialization (stage 1)

FIXME

System operation (stage 2)

In stage 2 runsvdir is run, running services declared in /var/service.

/var/service is on tmpfs, populated on boot from /usr/share/service directory. watchsv service watches files created and deleted in this directory and creates runit service definitions in /var/service.

In addition to static list in /usr/share/services there are "dynamic services" started and shut down as need arises. Those are created and removed by svdynservice utility, which reads template service definitions from /usr/share/dynservice and turns them into service instance under /var/service. Dynamic services are useful for programs being started as a result of various events, such as hardware events reported by kernel.

System shutdown (stage 3)

FIXME

Logging

Each service will have its logs stored under /var/log/<servicename> directory. This is accomplished by appendant log service created automatically.

HOWTO

How to run service in stage 2

Ship file /usr/share/service/mycoolservice in the package with the following contents:

exec mycoolservice 2>&1

See the  runsv manual for more details.

If you need to provide finish file, name it `mycoolservice.finish' and stick to the same directory.

Log service is provided by IPlinux.

How to add/remove services dynamically

Ship file /usr/share/dynservice/mydynservice in package with the following contents:

exec mydynservice @1@ @2@ 2>&1

If you need to create instance of dynamic service, run

svdynservice add instancename mydynservice arg1 arg2

@1@, @2@, ... will be substituted by positional parameters during service creation. @INSTANCE@ will be substituted by instance name.

If you need to destroy instance of dynamic service, run

svdynservice remove instancename