dinit.8.m4 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. changequote(`@@@',`$$$')dnl
  2. @@@.TH DINIT "8" "$$$MONTH YEAR@@@" "Dinit $$$VERSION@@@" "Dinit \- service management system"
  3. .SH NAME
  4. dinit \- supervise processes and manage services
  5. .\"
  6. .SH SYNOPSIS
  7. .\"
  8. .nh
  9. .\"
  10. .HP
  11. .B dinit
  12. [OPTION]... [\fIservice-name\fR]...
  13. .\"
  14. .hy
  15. .\"
  16. .SH DESCRIPTION
  17. .\"
  18. \fBDinit\fR is a process supervisor and service manager which can also
  19. function as a system \fBinit\fR process.
  20. It has a small but functional feature set, offering service dependency handling, parallel startup,
  21. automatic rate-limited restart of failing processes, and service control functions.
  22. .LP
  23. Dinit can be run as a system instance (when run as the root user or when
  24. specified via command line parameter) or as a user instance.
  25. This affects the default paths used to locate certain files.
  26. .LP
  27. When run as PID 1, the first process, Dinit by default acts as a system manager and
  28. shuts down or reboots the system on request (including on receipt of certain signals).
  29. This is currently fully supported only on Linux.
  30. See \fBRUNNING AS SYSTEM MANAGER / PRIMARY INIT\fR.
  31. .LP
  32. Dinit reads service descriptions from files located in a service
  33. description directory, normally one of \fI/etc/dinit.d\fR, \fI/run/dinit.d\fR,
  34. \fI/usr/local/lib/dinit.d\fR and \fI/lib/dinit.d\fR for the system instance
  35. or \fI$XDG_CONFIG_HOME/dinit.d\fR, \fI$HOME/.config/dinit.d\fR, \fI/etc/dinit.d/user\fR,
  36. \fI/usr/lib/dinit.d/user\fR and \fI/usr/local/lib/dinit.d/user\fR when run as a user process.
  37. See \fBSERVICE DESCRIPTION FILES\fR for details of the service description format.
  38. .\"
  39. .SH OPTIONS
  40. .TP
  41. \fB\-d\fR \fIdir\fP, \fB\-\-services\-dir\fR \fIdir\fP
  42. Specifies \fIdir\fP as the directory containing service definition files.
  43. This can be specified multiple times for multiple service directories.
  44. .IP
  45. The default service directories are listed in the \fBFILES\fR section.
  46. Note that the default directories will not be searched when the \fB\-d\fR/\fB\-\-services\-dir\fR
  47. option is specified.
  48. .TP
  49. \fB\-e\fR \fIfile\fP, \fB\-\-env\-file\fR \fIfile\fP
  50. Read initial environment from \fIfile\fP.
  51. For the system init process, the default is \fI/etc/dinit/environment\fR; see \fBFILES\fR.
  52. .TP
  53. \fB\-p\fR \fIpath\fP, \fB\-\-socket\-path\fR \fIpath\fP
  54. Specifies \fIpath\fP as the path to the control socket used to listen for
  55. commands from the \fBdinitctl\fR program.
  56. The default for the system service manager is usually \fI/dev/dinitctl\fR (but can be configured at build time).
  57. For a user service manager the default is either \fI$XDG_RUNTIME_DIR/dinitctl\fR
  58. or \fI$HOME/.dinitctl\fR, depending on whether \fI$XDG_RUNTIME_DIR\fR is set.
  59. .TP
  60. \fB\-F\fR \fIfd\fP, \fB\-\-ready\-fd\fR \fIfd\fP
  61. Specifies \fIfd\fP as the file descriptor number to report readiness to.
  62. Readiness means that the control socket is open and the service manager is
  63. ready to accept commands (e.g. via \fBdinitctl\fR). It does not mean that
  64. services are finished starting yet. The path to the currently open control
  65. socket is written on the file descriptor.
  66. .TP
  67. \fB\-l\fR \fIpath\fP, \fB\-\-log\-file\fR \fIpath\fP
  68. Species \fIpath\fP as the path to the log file, to which Dinit will log status
  69. and error messages.
  70. Using this option inhibits logging via the syslog facility, however, all logging messages are
  71. duplicated as usual to the console (as long as \fB\-\-quiet\fR has not also been specified).
  72. Note that when running as the system init, Dinit will continue if it cannot open the specified
  73. file, and will attempt to open it again once the root file system is writable.
  74. If not running as the system init and the file cannot be opened, Dinit will immediately exit
  75. with an error.
  76. .TP
  77. \fB\-s\fR, \fB\-\-system\fR
  78. Run as the system service manager.
  79. This is the default if invoked as the root user.
  80. This option affects the default service definition directory and control socket path.
  81. .TP
  82. \fB\-m\fR, \fB\-\-system\-mgr\fR
  83. Run as the system manager (perform operations directly related to machine startup
  84. and shutdown).
  85. This is the default when running as process ID 1.
  86. The main user-visible effect of this option is to invoke the \fB$$$SHUTDOWN_PREFIX@@@shutdown\fR program when a shutdown is
  87. requested (and after all services have stopped), and to provide some basic support
  88. for system recovery in case the \fBboot\fR service (or other specified service)
  89. cannot be started.
  90. .TP
  91. \fB\-u\fR, \fB\-\-user\fR
  92. Run as a user service manager.
  93. This is the opposite of \fB\-\-system\fR, and is the default if not invoked as the root user.
  94. .TP
  95. \fB\-o\fR, \fB\-\-container\fR
  96. Run in "container mode", i.e. do not perform system management functions (such
  97. as shutdown/reboot).
  98. The \fBdinit\fR daemon will simply exit rather than executing the \fB$$$SHUTDOWN_PREFIX@@@shutdown\fR program.
  99. .TP
  100. \fB\-r\fR, \fB\-\-auto\-recovery\fR
  101. Automatically run the \fIrecovery\fR service on apparent boot failures (if all
  102. services stop without a shutdown command having been issued) without prompting
  103. the user when Dinit is running as system manager.
  104. .TP
  105. \fB\-q\fR, \fB\-\-quiet\fR
  106. Run with no output to the terminal/console.
  107. This disables service status messages and sets the log level for the console log to \fBnone\fR.
  108. To re-enable (some) output, use the \fB\-\-console\-level\fR option after this option.
  109. .TP
  110. \fB\-b\fR \fIpath\fR, \fB\-\-cgroup\-path\fR \fIpath\fR
  111. Specify the path to resolve relative cgroup paths against.
  112. If service description settings contain relative cgroup paths, they will be resolved relative to
  113. this path.
  114. This option is only available if \fBdinit\fR is built with cgroups support.
  115. .TP
  116. \fB\-\-help\fR
  117. Display brief help text and then exit.
  118. .TP
  119. \fB\-\-version\fR
  120. Display version number and then exit.
  121. .TP
  122. [\fB\-t\fR] \fIservice-name\fR, [\fB\-\-service\fR] \fIservice-name\fR
  123. Specifies the name of a service that should be started (along with its
  124. dependencies).
  125. If none are specified, defaults to \fIboot\fR (which requires that a suitable service description
  126. for the \fIboot\fR service exists). Multiple services can be specified in which case they will each
  127. be started. An argument to the service may be included here.
  128. .sp
  129. \fBNote:\fR on Linux, if \fBdinit\fR is running as PID 1 and with UID 0, it may ignore "naked"
  130. service names (without preceding \fB\-\-service\fR/\fB\-t\fR) provided on the command line.
  131. See the \fBCOMMAND LINE FROM KERNEL\fR section.
  132. .TP
  133. \fB\-\-console\-level\fR \fIlevel\fR
  134. Specify the minimum log level of messages that should be logged to the console.
  135. From highest to lowest, the levels are \fBerror\fR, \fBwarn\fR, \fBinfo\fR and \fBdebug\fR.
  136. Use a level of \fBnone\fR to suppress all messages.
  137. Note that unless \fB\-\-quiet\fR (\fB\-q\fR) is also specified, service state change messages
  138. (service started, stopped etc) are always output.
  139. .TP
  140. \fB\-\-log\-level\fR \fIlevel\fR
  141. Specify the minimum log level of messages that should be sent to the primary log (syslog facility
  142. or file).
  143. From highest to lowest, the levels are \fBerror\fR, \fBwarn\fR, \fBinfo\fR and \fBdebug\fR.
  144. Use a level of \fBnone\fR to suppress all messages.
  145. .\"
  146. .SH SERVICE DESCRIPTION FILES
  147. .\"
  148. Service description files specify the parameters of each service.
  149. They are named for the service they describe, and are found in one of several directories
  150. (including \fI/etc/dinit.d\fR) for a system instance or \fI$XDG_CONFIG_HOME/dinit.d\fR and
  151. \fI$HOME/.config/dinit.d\fR for a user instance (see also \fB\-\-services\-dir\fR option).
  152. .LP
  153. Service description files are read by Dinit on an "as needed" basis.
  154. Once loaded, a service description is never automatically unloaded (even if the service
  155. stops or fails).
  156. A service description can however be unloaded (if the service is stopped) or reloaded
  157. (with some limitations) via \fBdinitctl\fR(8) using the \fBunload\fR and \fBreload\fR subcommands
  158. respectively.
  159. .LP
  160. See \fBdinit-service\fR(5) for details of the format and available parameters.
  161. .\"
  162. .SH SPECIAL SERVICE NAMES
  163. .\"
  164. There are two service names that are "special" to Dinit.
  165. .LP
  166. The \fIboot\fR service is the service that Dinit starts by default, if no
  167. other service names are provided when it is started.
  168. .LP
  169. The \fIrecovery\fR service is a service that Dinit will offer to start if
  170. boot appears to fail (that is, if all services stop without a shutdown command
  171. having been issued), when Dinit is running as system manager.
  172. .\"
  173. .SH OPERATION
  174. .\"
  175. On starting, Dinit starts the initial service(s) as specified on the command line.
  176. Starting a service also causes the dependencies of that service to start, and any service
  177. processes will not be launched until the dependencies are satisfied.
  178. Similarly, stopping a service first stops any dependent services.
  179. .LP
  180. During execution, Dinit accepts commands via a control socket which is created
  181. by Dinit when it starts.
  182. This can be used to order that a service be started or stopped, to determine service status, or to
  183. make certain configuration changes.
  184. See \fBdinitctl\fR(8) for details.
  185. Dinit attempts to check for the existence of an already-active socket first, and will refuse to
  186. start if one exists.
  187. Unfortunately, this check cannot be done atomically, and should not be relied upon generally as a
  188. means to avoid starting two instances of dinit.
  189. .LP
  190. Process-based services are monitored and, if the process terminates, the service may be stopped or
  191. the process may be re-started, according to the configuration in the service description.
  192. .LP
  193. Once all services stop, the \fBdinit\fR daemon will itself terminate (or, if
  194. running as system manager, will perform the appropriate type of system shutdown).
  195. .\"
  196. .SS SERVICE ACTIVATION MODEL
  197. .\"
  198. Dinit maintains a set of running services, some of which have been explicitly activated and some of
  199. which are active only because they are a dependency of another active service.
  200. Initially, only the \fBboot\fR service (or another service or services as specified via the command line)
  201. will be explicitly activated.
  202. There are both "hard" dependencies between services, and (various types of) "soft" dependencies;
  203. see \fBdinit-service\fR(5) for details.
  204. .LP
  205. For a service to start, all its hard dependencies must first start successfully; if any of them fail,
  206. the dependent will not be started.
  207. .LP
  208. In the case of services which are associated with an external process, the process will not be started
  209. until all hard dependencies have already started; in the case of a service which fails to start due
  210. to a dependency failing, the service command will never be run.
  211. .LP
  212. If a process associated with a running service terminates, the service will stop automatically
  213. (this can be affected by service settings, and the service may also restart automatically).
  214. If the service will not be automatically restarted, any explicit activation will be removed.
  215. When stopping a service with an associated running process, the process will not be signalled for
  216. termination (or have its termination command executed) until all dependent services have been stopped.
  217. .LP
  218. If a service stops, and is a hard dependency of another service, the other service must also stop
  219. (and will be stopped automatically, though may restart automatically if configured to do so, which
  220. may in turn also cause the dependency to restart).
  221. .LP
  222. Services can be explicitly activated using the \fBdinitctl\fR(8) subcommand, \fBstart\fR (activating
  223. a service will also cause it to start, if it is not already started).
  224. Explicit activation can be removed using the \fBrelease\fR subcommand (which will stop the service only if
  225. it is not also a dependency of another active service). Note that the \fBstop\fR subcommand also removes
  226. explicit activation, but can fail with no effect if the service will not be stopped (due to being a
  227. dependency of another active service).
  228. .LP
  229. If a running service is not explicitly activated and has no running dependents, it will be stopped.
  230. As a consequence, a service stopping may result in some or all of its dependencies also stopping.
  231. A general rule is that starting a service by explicitly activating it will also start any of its
  232. dependencies which are not currently started, and that then stopping the same service will result
  233. in the same set of dependencies also stopping; there are exceptions to this, however - in particular,
  234. a stopped service which is a soft dependency of an otherwise unrelated active service may be
  235. started as a result of the starting of a third service, of which it is also a dependency, and in
  236. this case the third service stopping again will not cause the first to stop, since the second
  237. service remains an active dependent (it is not likely that this particular quirk of behaviour
  238. will ever be problematic or even noticed, but it is described here for completeness).
  239. .\"
  240. .SS CHARACTER SET HANDLING
  241. .\"
  242. Dinit does no character set translation.
  243. Dinit's own output is in the execution character set as determined at compilation, as is the interpretation of input.
  244. Service names (and other user-defined inputs) are interpreted as byte sequences and are output as they were read.
  245. In general, modern systems use the UTF-8 character set universally and no problems will arise;
  246. however, systems configured to use other character sets may see odd behaviour if the input
  247. character set does not match the output character set, or if either input or output character sets
  248. are not a superset of the execution character set.
  249. .\"
  250. .SS RUNNING AS SYSTEM MANAGER / PRIMARY INIT
  251. .\"
  252. Running as the system manager (primary \fBinit\fR) is currently supported only on
  253. Linux.
  254. When run as process ID 1, the \fBdinit\fR daemon by default assumes responsibility for
  255. system shutdown and restart (partially relying on external utilities which are
  256. part of the Dinit distribution).
  257. .LP
  258. When not running as a system manager, \fBdinit\fR assumes responsibility only for
  259. service management.
  260. System shutdown or restart need to be handled by the primary \fBinit\fR, which should start
  261. \fBdinit\fR on normal startup, and terminate \fBdinit\fR before shutdown, by signalling it and
  262. waiting for it to terminate after stopping services (possibly by invoking \fBdinitctl shutdown\fR).
  263. .\"
  264. .SH LOGGING
  265. Dinit "logs" via two mechanisms simultaneously: the "console" (standard output, not necessarily associated
  266. with an actual console if \fBdinit\fR was started with output directed elsewhere) and the "main log facility"
  267. which is the syslog facility by default but which may be directed to a file.
  268. .LP
  269. Various options are available to control the types and "levels" of message that will be sent to each facility,
  270. and the destination of the main facility.
  271. The levels available (from low to high) are \fBdebug\fR, \fBnotice\fR, \fBwarn\fR, and \fBerror\fR.
  272. Selecting a particular log level for facility will cause the facility to receive messages of that level and higher.
  273. The special level \fBnone\fR inhibits a facility from receiving any messages.
  274. .LP
  275. Service status messages (service started or stopped) have a nominal level of \fBnotice\fR, except for failure
  276. which has a level of \fBerror\fR or \fBwarn\fR in case of transitive failure (due to a dependency).
  277. These messages are, by default, always issued to the console regardless of level, unless the \fB\-\-quiet\fR
  278. (\fB\-q\fR) option has been used.
  279. .LP
  280. To debug boot issues it may be useful to use \fB\-q\fR (which also sets the level to \fBnone\fR) and then
  281. also reset the level via the \fB\-\-console\-level\fR option to either \fBwarn\fR or \fBerror\fR.
  282. This will reduce noise in the output from successful service startup.
  283. .\"
  284. .SH COMMAND LINE FROM KERNEL
  285. .LP
  286. When running as PID 1, \fBdinit\fR may process the command line differently, to compensate for kernel behaviour.
  287. .LP
  288. On Linux, kernel command line options that are not recognised by the kernel will be passed on to \fBdinit\fR.
  289. However, bugs in some kernel versions may cause some options that are recognised to also be passed to \fBdinit\fR.
  290. Also, boot managers may insert command-line options such as "\fBauto\fR" (which indicates an "unattended" boot).
  291. Therefore, \fBdinit\fR ignores all "word like" options other than "\fBsingle\fR", which it treats as
  292. the name of the service to start (thus allowing "single user mode", assuming that a suitable service description exists).
  293. Options beginning with "\fB--\fR" will not be recognised by the kernel and will be passed to (and processed by) \fBdinit\fR;
  294. for example \fB\-\-quiet\fR can be used to suppress console output. Options containing "=" that are unrecognised by the
  295. kernel (or some that are, due to bugs) are passed to init via the environment rather than via the command line.
  296. .LP
  297. There are several ways to work around this.
  298. Service names following the \fB\-\-container\fR (\fB\-o\fR) or \fB\-\-system\-mgr\fR (\fB\-m\fR) options are not ignored.
  299. Also, the \fB\-\-service\fR (\fB\-t\fR) option can be used to force a service name to be recognised regardless of operating mode.
  300. .\"
  301. .SH FILES
  302. .\"
  303. .TP
  304. \fI/etc/dinit/environment\fR
  305. Default location of the environment file for Dinit when run as a system
  306. instance (for user instances there is no default).
  307. Values are specified as \fINAME\fR=\fIVALUE\fR, one per line, and add to and replace variables present
  308. in the environment when Dinit started (the "original environment").
  309. Lines beginning with a hash character (#) are ignored.
  310. .IP
  311. The following special commands can be used (each on a single line):
  312. .RS
  313. .TP
  314. \fB!clear\fR
  315. Clears the environment completely (prevents inheritance of any variables from the original environment).
  316. .TP
  317. \fB!unset\fR \fIvar-name\fR...
  318. Unsets the specified variables.
  319. Any previously specified value for these variables is forgotten, and they will not inherit any
  320. value from the original environment.
  321. .TP
  322. \fB!import\fR \fIvar-name\fR...
  323. Imports the value of the named variables from the original environment, overriding the effect of any
  324. value set previously as well as the effect of previous \fB!unset\fR and \fB!clear\fR commands.
  325. .RE
  326. .TP
  327. \fI/etc/dinit.d\fR, \fI/run/dinit.d\fR, \fI/usr/local/lib/dinit.d\fR, \fI/lib/dinit.d\fR
  328. Default locations for service description files. The directories are searched in the order listed.
  329. .TP
  330. \fI$XDG_CONFIG_HOME/dinit.d\fR, \fI$HOME/.config/dinit.d\fR, \fI/etc/dinit.d/user\fR, \fI/usr/lib/dinit.d/user\fR, \fI/usr/local/lib/dinit.d/user\fR
  331. Default location for service description files for user instances. The directories are searched in the order listed.
  332. .\"
  333. .SH SIGNALS
  334. .LP
  335. When run as a system manager, SIGINT stops all services and performs a reboot (on Linux, this signal can be
  336. generated using the control-alt-delete key combination); SIGTERM stops services and halts the system; and
  337. SIGQUIT performs an immediate shutdown with no service rollback.
  338. .LP
  339. When run as a user process or system service manager only, SIGINT and SIGTERM both stop services
  340. and exit Dinit; SIGQUIT exits Dinit immediately.
  341. .\"
  342. .SH SEE ALSO
  343. .\"
  344. \fBdinitctl\fR(8), \fBdinit-service\fR(5), \fBdinitcheck\fR(8), \fB$$$SHUTDOWN_PREFIX@@@shutdown(8)\fR.
  345. .\"
  346. .SH AUTHOR
  347. Dinit, and this manual, were written by Davin McCall.
  348. $$$dnl