Documentation updates
[oweals/dinit.git] / README
1 Dinit
2 -----
3 v0.1 (pre-release)
4
5
6 What is it?
7 =-=-=-=-=-=
8
9 "Dinit" is a service supervisor with dependency support which can also
10 act as the system "init" program.
11
12 Specifically it can launch multiple services (generally, "daemon" processes,
13 but see notes below) in parallel, with dependency management (i.e. if one
14 service's operation depends on another, the latter service will be started
15 first).
16
17 For "process" services dinit can monitor the process corresponding to the
18 service, and re-start it if it dies. It does this in an intelligent way,
19 first "rolling back" all dependent services (which it will later re-start,
20 if configured to do so).
21
22 Dinit is designed to work on POSIXy operating systems such as Linux and
23 OpenBSD. It is written in C++ and uses the "libev" event handling library.
24
25 See doc/COMPARISON for a comparison of Dinit with similar software packages.
26
27 The primary author of Dinit is Davin McCall <davmac@davmac.org>.
28
29
30 Introduction to services
31 =-=-=-=-=-=-=-=-=-=-=-=-
32
33 A "service" is nominally a persistent process or system state. The two main
34 types of service are a _process_ service (represented by a an actual process)
35 and a _scripted_ service (which is started and stopped by running a process -
36 often a shell script - to completion).
37
38 Many programs that you might want to run under dinit's supervision can run
39 either "in the foreground" or as a daemon ("in the background"), and the
40 choice is dictated by a command line switch (for instance the -D and -F
41 switches to Samba's "smbd"). Although it might seem counterintuitive,
42 the "foreground" mode should be used for programs registered as process
43 services in dinit; this allows dinit to monitor the process.
44
45 Process services are attractive due to the ease of monitoring (and
46 restarting) the service, however, they have one inherent problem, which is
47 that dinit cannot tell when the service is truly started. Once the process
48 has been launched, dinit assumes that the service has started, but in fact
49 there will be a short delay before the process sets itself up, starts
50 listening on sockets, etc; during this time any other process (including
51 one from a service listed as dependent) which tries to contact it will not
52 be able to do so. In practice, this is not usually a problem (and external
53 solutions, like D-Bus, do exist).
54
55
56
57 Service Description files
58 =-=-=-=-=-=-=-=-=-=-=-=-=
59
60 Dinit discovers services by reading _service description files_. These files
61 reside in a directory (/etc/dinit.d is the default "system" location) and
62 their name matches the name of the service. Service descriptions are loaded
63 lazily, as needed by Dinit.
64
65 A service description file consists of a number of parameter settings.
66 Settings in the SDF are denoted as a parameter name followed by either an
67 equal sign or colon and then the parameter value (all on the same line).
68 Comments begin with a hash mark (#) and extend to the end of the line.
69
70 Parameter values are interpreted literally, except that:
71  - whitespace is collapsed to a single space
72  - double quotes can be used around all or part(s) of a parameter to prevent
73    whitespace collapse and interpretation of special characters
74  - backslash can be used to 'escape' the next character, preventing any
75    special meaning from being associated with it. It can be used to include
76    non-collapsing whitespace, double-quote marks, and backslashes in the
77    parameter value.
78
79 Parameters are:
80
81 type = process | scripted | internal
82 command = ...
83 restart = yes | true | no | false
84 logfile = ...
85 onstart = ...
86 depends-on = (service name)
87 waits-for = (service name)
88
89 command = (external script or executable and arguments)
90    For a 'process' service, this is the process to run.
91    For a 'scripted' service, this process is run both to start the service
92    (with the command-line argument "start" appended) and to stop the
93    service (with "stop").
94  
95 onstart = (internal commands)
96    release_console - stop performing output to the console (usually used
97               when login prompt is spawned)
98    rw_ready - try again to open any logs, control socket etc that could not
99               be opened previously due to a read-only filesystem.
100
101 depends-on = (service name)
102    This service depends on the named service. Starting this service will
103    start the named service; the command to start this service will not be
104    executed until the named service has started. If the named service is
105    stopped then this service will also be stopped.
106
107 waits-for = (service name)
108    When this service is started, wait for the named service to finish
109    starting (or to fail starting) before commencing the start procedure
110    for this service. Starting this service will automatically start
111    the named service.