dinit.8.m4 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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,
  34. \fI/usr/local/lib/dinit.d\fR or \fI/lib/dinit.d\fR for the system instance
  35. or just \fI$HOME/.config/dinit.d\fR when run as a user process.
  36. See \fBSERVICE DESCRIPTION FILES\fR for details of the service description format.
  37. .\"
  38. .SH OPTIONS
  39. .TP
  40. \fB\-d\fR \fIdir\fP, \fB\-\-services\-dir\fR \fIdir\fP
  41. Specifies \fIdir\fP as the directory containing service definition files.
  42. This can be specified multiple times for multiple service directories.
  43. The default directories are not searched for services when this option is provided.
  44. .sp
  45. If not specified, the default is \fI$HOME/.config/dinit.d\fR or, for the
  46. system service manager, each of \fI/etc/dinit.d\fR, \fI/usr/local/lib/dinit.d\fR,
  47. and \fI/lib/dinit.d\fR (searched in that order).
  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. Note that when running as the system service manager, Dinit
  71. does not begin logging until the log service has started.
  72. Using this option inhibits logging via the syslog facility, however, all logging messages are
  73. duplicated as usual to the console (so long as no service owns the console).
  74. .TP
  75. \fB\-s\fR, \fB\-\-system\fR
  76. Run as the system service manager.
  77. This is the default if invoked as the root user.
  78. This option affects the default service definition directory and control socket path.
  79. .TP
  80. \fB\-m\fR, \fB\-\-system\-mgr\fR
  81. Run as the system manager (perform operations directly related to machine startup
  82. and shutdown).
  83. This is the default when running as process ID 1.
  84. The main user-visible effect of this option is to invoke the \fB$$$SHUTDOWN_PREFIX@@@shutdown\fR program when a shutdown is
  85. requested (and after all services have stopped), and to provide some basic support
  86. for system recovery in case the \fBboot\fR service (or other specified service)
  87. cannot be started.
  88. .TP
  89. \fB\-u\fR, \fB\-\-user\fR
  90. Run as a user service manager.
  91. This is the opposite of \fB\-\-system\fR, and is the default if not invoked as the root user.
  92. .TP
  93. \fB\-o\fR, \fB\-\-container\fR
  94. Run in "container mode", i.e. do not perform system management functions (such
  95. as shutdown/reboot).
  96. The \fBdinit\fR daemon will simply exit rather than executing the \fB$$$SHUTDOWN_PREFIX@@@shutdown\fR program.
  97. .TP
  98. \fB\-q\fR, \fB\-\-quiet\fR
  99. Run with no output to the terminal/console.
  100. This disables service status messages and sets the log level for the console log to \fBNONE\fR.
  101. .TP
  102. \fB\-b\fR \fIpath\fR, \fB\-\-cgroup\-path\fR \fIpath\fR
  103. Specify the path to resolve relative cgroup paths against.
  104. If service description settings contain relative cgroup paths, they will be resolved relative to
  105. this path.
  106. This option is only available if \fBdinit\fR is built with cgroups support.
  107. .TP
  108. \fB\-\-help\fR
  109. Display brief help text and then exit.
  110. .TP
  111. \fB\-\-version\fR
  112. Display version number and then exit.
  113. .TP
  114. [\fB\-t\fR] \fIservice-name\fR, [\fB\-\-service\fR] \fIservice-name\fR
  115. Specifies the name of a service that should be started (along with its
  116. dependencies).
  117. If none are specified, defaults to \fIboot\fR (which requires that a suitable service description
  118. for the \fIboot\fR service exists). Multiple services can be specified in which case they will each
  119. be started.
  120. .sp
  121. \fBNote:\fR on Linux, if \fBdinit\fR is running as PID 1 and with UID 0, it may ignore "naked"
  122. service names (without preceding \fB\-\-service\fR/\fB\-t\fR) provided on the command line.
  123. See the \fBCOMMAND LINE FROM KERNEL\fR section.
  124. .\"
  125. .SH SERVICE DESCRIPTION FILES
  126. .\"
  127. Service description files specify the parameters of each service.
  128. They are named for the service they describe, and are found in \fI/etc/dinit.d\fR
  129. for a system instance or \fI$HOME/.config/dinit.d\fR for a user instance.
  130. .LP
  131. Service description files are read by Dinit on an "as needed" basis.
  132. Once loaded, a service description is never automatically unloaded (even if the service
  133. stops or fails).
  134. A service description can however be unloaded (if the service is stopped) or reloaded
  135. (with some limitations) via \fBdinitctl\fR(8) using the \fBunload\fR and \fBreload\fR subcommands
  136. respectively.
  137. .LP
  138. See \fBdinit-service\fR(5) for details of the format and available parameters.
  139. .\"
  140. .SH SPECIAL SERVICE NAMES
  141. .\"
  142. There are two service names that are "special" to Dinit.
  143. .LP
  144. The \fIboot\fR service is the service that Dinit starts by default, if no
  145. other service names are provided when it is started.
  146. .LP
  147. The \fIrecovery\fR service is a service that Dinit will offer to start if
  148. boot appears to fail (that is, if all services stop without a shutdown command
  149. having been issued), when Dinit is running as system manager.
  150. .\"
  151. .SH OPERATION
  152. .\"
  153. On starting, Dinit starts the initial service(s) as specified on the command line.
  154. Starting a service also causes the dependencies of that service to start, and any service
  155. processes will not be launched until the dependencies are satisfied.
  156. Similarly, stopping a service first stops any dependent services.
  157. .LP
  158. During execution, Dinit accepts commands via a control socket which is created
  159. by Dinit when it starts.
  160. This can be used to order that a service be started or stopped, to determine service status, or to
  161. make certain configuration changes.
  162. See \fBdinitctl\fR(8) for details.
  163. Dinit attempts to check for the existence of an already-active socket first, and will refuse to
  164. start if one exists.
  165. Unfortunately, this check cannot be done atomically, and should not be relied upon generally as a
  166. means to avoid starting two instances of dinit.
  167. .LP
  168. Process-based services are monitored and, if the process terminates, the service may be stopped or
  169. the process may be re-started, according to the configuration in the service description.
  170. .LP
  171. Once all services stop, the \fBdinit\fR daemon will itself terminate (or, if
  172. running as system manager, will perform the appropriate type of system shutdown).
  173. .\"
  174. .SS CHARACTER SET HANDLING
  175. .\"
  176. Dinit does no character set translation.
  177. Dinit's own output is in the execution character set as determined at compilation, as is the interpretation of input.
  178. Service names (and other user-defined inputs) are interpreted as byte sequences and are output as they were read.
  179. In general, modern systems use the UTF-8 character set universally and no problems will arise;
  180. however, systems configured to use other character sets may see odd behaviour if the input
  181. character set does not match the output character set, or if either input or output character sets
  182. are not a superset of the execution character set.
  183. .\"
  184. .SS RUNNING AS SYSTEM MANAGER / PRIMARY INIT
  185. .\"
  186. Running as the system manager (primary \fBinit\fR) is currently supported only on
  187. Linux.
  188. When run as process ID 1, the \fBdinit\fR daemon by default assumes responsibility for
  189. system shutdown and restart (partially relying on external utilities which are
  190. part of the Dinit distribution).
  191. .LP
  192. When not running as a system manager, \fBdinit\fR assumes responsibility only for
  193. service management.
  194. System shutdown or restart need to be handled by the primary \fBinit\fR, which should start
  195. \fBdinit\fR on normal startup, and terminate \fBdinit\fR before shutdown, by signalling it and
  196. waiting for it to terminate after stopping services (possibly by invoking \fBdinitctl shutdown\fR).
  197. .\"
  198. .SH COMMAND LINE FROM KERNEL
  199. .LP
  200. When running as PID 1, \fBdinit\fR may process the command line differently, to compensate for kernel behaviour.
  201. .LP
  202. On Linux, kernel command line options that are not recognised by the kernel will be passed on to \fBdinit\fR.
  203. However, bugs in some kernel versions may cause some options that are recognised to also be passed to \fBdinit\fR.
  204. Also, boot managers may insert command-line options such as "\fBauto\fR" (which indicates an "unattended" boot).
  205. Therefore, \fBdinit\fR ignores all "word like" options other than "\fBsingle\fR", which it treats as
  206. the name of the service to start (thus allowing "single user mode", assuming that a suitable service description exists).
  207. Options beginning with "\fB--\fR" will not be recognised by the kernel and will be passed to (and processed by) \fBdinit\fR;
  208. for example \fB\-\-quiet\fR can be used to suppress console output. Options containing "=" that are unrecognised by the
  209. kernel (or some that are, due to bugs) are passed to init via the environment rather than via the command line.
  210. .LP
  211. There are several ways to work around this.
  212. Service names following the \fB\-\-container\fR (\fB\-o\fR) or \fB\-\-system\-mgr\fR (\fB\-m\fR) options are not ignored.
  213. Also, the \fB\-\-service\fR (\fB\-t\fR) option can be used to force a service name to be recognised regardless of operating mode.
  214. .\"
  215. .SH FILES
  216. .\"
  217. .TP
  218. \fI/etc/dinit/environment\fR
  219. Default location of the environment file for Dinit when run as a system
  220. instance (for user instances there is no default).
  221. Values are specified as \fINAME\fR=\fIVALUE\fR, one per line, and add to and replace variables present
  222. in the environment when Dinit started (the "original environment").
  223. Lines beginning with a hash character (#) are ignored.
  224. .IP
  225. The following special commands can be used (each on a single line):
  226. .RS
  227. .TP
  228. \fB!clear\fR
  229. Clears the environment completely (prevents inheritance of any variables from the original environment).
  230. .TP
  231. \fB!unset\fR \fIvar-name\fR...
  232. Unsets the specified variables.
  233. Any previously specified value for these variables is forgotten, and they will not inherit any
  234. value from the original environment.
  235. .TP
  236. \fB!import\fR \fIvar-name\fR...
  237. Imports the value of the named variables from the original environment, overriding the effect of any
  238. value set previously as well as the effect of previous \fB!unset\fR and \fB!clear\fR commands.
  239. .RE
  240. .TP
  241. \fI/etc/dinit.d\fR, \fI/usr/local/lib/dinit.d\fR, \fI/lib/dinit.d\fR
  242. Default locations for service description files. The directories are searched in the order listed.
  243. .TP
  244. \fI$HOME/.config/dinit.d\fR
  245. Default location for service description files for user instances.
  246. .\"
  247. .SH SIGNALS
  248. .LP
  249. When run as a system manager, SIGINT stops all services and performs a reboot (on Linux, this signal can be
  250. generated using the control-alt-delete key combination); SIGTERM stops services and halts the system; and
  251. SIGQUIT performs an immediate shutdown with no service rollback.
  252. .LP
  253. When run as a user process or system service manager only, SIGINT and SIGTERM both stop services
  254. and exit Dinit; SIGQUIT exits Dinit immediately.
  255. .\"
  256. .SH SEE ALSO
  257. .\"
  258. \fBdinitctl\fR(8), \fBdinit-service\fR(5), \fBdinitcheck\fR(8), \fB$$$SHUTDOWN_PREFIX@@@shutdown(8)\fR.
  259. .\"
  260. .SH AUTHOR
  261. Dinit, and this manual, were written by Davin McCall.
  262. $$$dnl