dinit-service.5.m4 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. changequote(`@@@',`$$$')dnl
  2. @@@.TH DINIT-SERVICE "5" "$$$MONTH YEAR@@@" "Dinit $$$VERSION@@@" "Dinit \- service management system"
  3. .SH NAME
  4. Dinit service description files
  5. .\"
  6. .SH SYNOPSIS
  7. .\"
  8. .ft CR
  9. /etc/dinit.d/\fIservice-name\fR, $HOME/.config/dinit.d/\fIservice-name\fR
  10. .ft
  11. .\"
  12. .SH DESCRIPTION
  13. .\"
  14. The service description files for \fBDinit\fR each describe a service. The name
  15. of the file corresponds to the name of the service it describes.
  16. .LP
  17. Service description files specify the various attributes of a service. A
  18. service description file is named after the service it represents, and is
  19. a plain-text file with simple key-value format.
  20. The description files are located in a service description directory; by default,
  21. the system process searches \fI/etc/dinit.d\fR, \fI/usr/local/lib/dinit.d\fR and
  22. \fI/lib/dinit.d\fR, while a user process searches \fI$HOME/.config/dinit.d\fR.
  23. .LP
  24. All services have a \fItype\fR and a set of \fIdependencies\fR. These are discussed
  25. in the following subsections. The type, dependencies, and other attributes are
  26. specified via property settings, the format of which are documented in the
  27. \fBSERVICE PROPERTIES\fR subsection, which also lists the available properties.
  28. .\"
  29. .SS SERVICE TYPES
  30. .\"
  31. There are five basic types of service:
  32. .IP \(bu
  33. \fBProcess\fR services. This kind of service runs as a single process; starting
  34. the service simply requires starting the process; stopping the service is
  35. accomplished by stopping the process (via sending it a signal).
  36. .IP \(bu
  37. \fBBgprocess\fR services ("background process" services). This kind of
  38. service is similar to a regular process service, but the process daemonizes
  39. or otherwise forks from the original process which starts it, and the
  40. process ID is written to a file.
  41. Dinit can read the process ID from the file and, if it is running as the system
  42. init process, can supervise it.
  43. .IP \(bu
  44. \fBScripted\fR services are services which are started and stopped by a
  45. command (which need not actually be a script, despite the name).
  46. They can not be supervised.
  47. .IP \(bu
  48. \fBInternal\fR services do not run as an external process at all. They can
  49. be started and stopped without any external action.
  50. They are useful for grouping other services (via service dependencies).
  51. .IP \(bu
  52. \fbTriggered\fR services are similar to internal processes, but an external
  53. trigger is required before they will start (i.e. their startup will pause until
  54. the trigger occurs).
  55. The \fBdinitctl trigger\fR command can be used to trigger such a service;
  56. see \fBdinitctl\fR(8).
  57. .LP
  58. Independent of their type, the state of services can be linked to other
  59. services via dependency relationships, which are discussed in the next section.
  60. .\"
  61. .SS SERVICE DEPENDENCIES
  62. .\"
  63. A service dependency relationship, broadly speaking, specifies that for one
  64. service to run, another must also be running.
  65. The first service is the \fIdependent\fR service and the latter is the \fIdependency\fR
  66. service (we will henceforth generally refer to the the dependency relationship as the
  67. \fIrelationship\fR and use \fIdependency\fR to refer to the service).
  68. A dependency relationship is specified via the properties of the dependent.
  69. There are different relationship types, as follows:
  70. .IP \(bu
  71. A \fBneed\fR (or "hard") relationship specifies that the dependent must wait
  72. for the dependency to be started before it starts, and that the dependency
  73. must remain started while the dependent is started.
  74. Starting the dependent will start the dependency, and stopping the dependency will stop the
  75. dependent. This type of relationship is specified using a \fBdepends-on\fR property.
  76. .IP \(bu
  77. A \fBmilestone\fR relationship specifies that the dependency must
  78. start successfully before the dependent starts.
  79. Starting the dependent will therefore start the dependency.
  80. Once started, the relationship is satisfied; if the dependency then stops, it
  81. has no effect on the dependent.
  82. However, if the dependency fails to start or has its startup cancelled, the dependent will
  83. not start (and will return to the stopped state).
  84. This type of relationship is specified using a \fBdepends-ms\fR property.
  85. .IP \(bu
  86. A \fBwaits-for\fR relationship specifies that the dependency must
  87. start successfully, or fail to start, before the dependent starts.
  88. Starting the dependent will attempt to first start the dependency, but failure will
  89. not prevent the dependent from starting.
  90. If the dependency starts, stopping it will have no effect on the dependent.
  91. This type of relationship is specified using a \fBwaits-for\fR property.
  92. .LP
  93. Note that process-based services always wait for their dependency relationships
  94. to be satisfied (by the dependency starting, or failing to start in case of a waits-for
  95. relationship) before their process is launched.
  96. Conversely, a termination signal will not in general be sent to a service process until
  97. the service has no active dependents.
  98. .LP
  99. Since in general dependencies should remain started so long as their dependent
  100. does, an attachment forms between the two once both are started.
  101. This attachment is released when the dependent stops, and the dependency will then stop, unless
  102. it has other attachments or it has been explicitly started independently.
  103. Attachments between a dependent and dependency are re-created if a dependency
  104. starts (or starts again) while the dependent is still started.
  105. .\"
  106. .SS SERVICE PROPERTIES
  107. .\"
  108. This section described the various service properties that can be specified
  109. in a service description file. The properties specify the type of the service,
  110. dependencies of the service, and other service configuration.
  111. .LP
  112. Each line of the file can specify a single
  113. property value, expressed as `\fIproperty-name\fR = \fIvalue\fR'. Comments
  114. begin with a hash mark (#) and extend to the end of the line (they must be
  115. separated from setting values by at least one whitespace character).
  116. Values are interpreted literally, except that:
  117. .\"
  118. .IP \(bu
  119. White space (comprised of spaces, tabs, etc) is collapsed to a single space, except
  120. leading or trailing white space around the property value, which is stripped.
  121. .IP \(bu
  122. Double quotes (") can be used around all or part of a property value, to
  123. prevent whitespace collapse and prevent interpretation of other special
  124. characters (such as "#") inside the quotes.
  125. The quote characters are not considered part of the property value.
  126. .IP \(bu
  127. A backslash (\\) can be used to escape the next character, causing it to
  128. lose any special meaning and become part of the property value.
  129. A double backslash (\\\\) is collapsed to a single backslash within the parameter value.
  130. .LP
  131. Setting a property generally overrides any previous setting (from prior lines).
  132. However some properties are set additively; these include dependency relationships and \fBoptions\fR
  133. properties.
  134. .LP
  135. The following properties can be specified:
  136. .TP
  137. \fBtype\fR = {process | bgprocess | scripted | internal | triggered}
  138. Specifies the service type; see the \fBSERVICE TYPES\fR section.
  139. .TP
  140. \fBcommand\fR = \fIcommand-string\fR
  141. Specifies the command, including command-line arguments, for starting the process.
  142. Applies only to \fBprocess\fR, \fBbgprocess\fR and \fBscripted\fR services.
  143. .TP
  144. \fBstop\-command\fR = \fIcommand-string\fR
  145. Specifies the command to stop the service (optional). Applicable to \fBprocess\fR, \fBbgprocess\fR and
  146. \fBscripted\fR services. If specified for \fBprocess\fR or \fBbgprocess\fR services, the "stop
  147. command" will be executed in order to stop the service, instead of signalling the service process.
  148. .TP
  149. \fBworking\-dir\fR = \fIdirectory\fR
  150. Specifies the working directory for this service. For a scripted service, this
  151. affects both the start command and the stop command.
  152. The value is subject to variable substitution (see \fBVARIABLE SUBSTITUTION\fR).
  153. .TP
  154. \fBrun\-as\fR = \fIuser-id\fR
  155. Specifies which user to run the process(es) for this service as.
  156. Specify as a username or numeric ID.
  157. If specified by name, the group for the process will also be set to the primary
  158. group of the specified user.
  159. .TP
  160. \fBenv\-file\fR = \fIfile\fR
  161. Specifies a file containing value assignments for environment variables, in the same
  162. format recognised by the \fBdinit\fR command's \fB\-\-env\-file\fR option (see \fBdinit\fR(5)).
  163. The file is read when the service is loaded, therefore values from it can be used in substitutions.
  164. .sp
  165. That means this path is static and cannot itself have variable substitutions (see \fBVARIABLE SUBSTITUTION\fR).
  166. .TP
  167. \fBrestart\fR = {yes | true | no | false}
  168. Indicates whether the service should automatically restart if it stops, including due to
  169. unexpected process termination or a dependency stopping.
  170. Note that if a service stops due to user request, automatic restart is inhibited.
  171. The default is to automatically restart.
  172. .TP
  173. \fBsmooth\-recovery\fR = {yes | true | no | false}
  174. Applies only to \fBprocess\fR and \fBbgprocess\fR services.
  175. When set true/yes, an automatic process restart can be performed without first stopping any
  176. dependent services.
  177. This setting is meaningless if the \fBrestart\fR setting is set to false.
  178. .TP
  179. \fBrestart\-delay\fR = \fIXXX.YYYY\fR
  180. Specifies the minimum time (in seconds) between automatic restarts. Enforcing a sensible
  181. minimum prevents Dinit from consuming a large number of process cycles in case a process
  182. continuously fails immediately after it is started.
  183. The default is 0.2 (200 milliseconds).
  184. .TP
  185. \fBrestart\-limit\-interval\fR = \fIXXX.YYYY\fR
  186. Sets the interval (in seconds) over which restarts are limited.
  187. If a process automatically restarts more than a certain number of times (specified by the
  188. \fBrestart-limit-count\fR setting) in this time interval, it will not be restarted again.
  189. The default value is 10 seconds.
  190. .TP
  191. \fBrestart\-limit\-count\fR = \fINNN\fR
  192. Specifies the maximum number of times that a service can automatically restart
  193. over the interval specified by \fBrestart\-limit\-interval\fR.
  194. Specify a value of 0 to disable the restart limit.
  195. The default value is 3.
  196. .TP
  197. \fBstart\-timeout\fR = \fIXXX.YYY\fR
  198. Specifies the time in seconds allowed for the service to start.
  199. If the service takes longer than this, its process group is sent a SIGINT signal
  200. and enters the "stopping" state (this may be subject to a stop timeout, as
  201. specified via \fBstop\-timeout\fR, after which the process group will be
  202. terminated via SIGKILL).
  203. The timeout period begins only when all dependencies have been stopped.
  204. The default timeout is 60 seconds.
  205. Specify a value of 0 to allow unlimited start time.
  206. .TP
  207. \fBstop\-timeout\fR = \fIXXX.YYY\fR
  208. Specifies the time in seconds allowed for the service to stop.
  209. If the service takes longer than this, its process group is sent a SIGKILL signal
  210. which should cause it to terminate immediately.
  211. The timeout period begins only when all dependent services have already stopped.
  212. The default timeout is 10 seconds.
  213. Specify a value of 0 to allow unlimited stop time.
  214. .TP
  215. \fBpid\-file\fR = \fIpath-to-file\fR
  216. For \fBbgprocess\fR type services only; specifies the path of the file where
  217. daemon will write its process ID before detaching.
  218. Dinit will read the contents of this file when starting the service, once the initial process
  219. exits, and will supervise the process with the discovered process ID.
  220. Dinit may also send signals to the process ID to stop the service; if \fBdinit\fR runs as a
  221. privileged user the path should therefore not be writable by unprivileged users.
  222. .sp
  223. The value is subject to variable substitution (see \fBVARIABLE SUBSTITUTION\fR).
  224. .TP
  225. \fBdepends\-on\fR = \fIservice-name\fR
  226. This service depends on the named service.
  227. Starting this service will start the named service; the command to start this service will not be executed
  228. until the named service has started.
  229. If the named service is stopped then this service will also be stopped.
  230. .TP
  231. \fBdepends\-ms\fR = \fIservice-name\fR
  232. This service has a "milestone" dependency on the named service. Starting this
  233. service will start the named service; this service will not start until the
  234. named service has started, and will fail to start if the named service does
  235. not start.
  236. Once the named (dependent) service reaches the started state, however, the
  237. dependency may stop without affecting the dependent service.
  238. .TP
  239. \fBwaits\-for\fR = \fIservice-name\fR
  240. When this service is started, wait for the named service to finish starting
  241. (or to fail starting) before commencing the start procedure for this service.
  242. Starting this service will automatically start the named service.
  243. If the named service fails to start, this service will start as usual (subject to
  244. other dependencies being met).
  245. .TP
  246. \fBwaits\-for.d\fR = \fIdirectory-path\fR
  247. For each file name in \fIdirectory-path\fR which does not begin with a dot,
  248. add a \fBwaits-for\fR dependency to the service with the same name.
  249. Note that contents of files in the specified directory are not significant; expected
  250. usage is to have symbolic links to the associated service description files,
  251. but this is not required.
  252. Failure to read the directory contents, or to find any of the services named within,
  253. is not considered fatal.
  254. .sp
  255. The directory path, if not absolute, is relative to the directory containing the service
  256. description file.
  257. .TP
  258. \fBafter\fR = \fIservice-name\fR
  259. When starting this service, if the named service is also starting, wait for the named service
  260. to finish starting before bringing this service up. This is similar to a \fBwaits\-for\fR
  261. dependency except no dependency relationship is implied; if the named service is not starting,
  262. starting this service will not cause it to start (nor wait for it in that case).
  263. .TP
  264. \fBbefore\fR = \fIservice-name\fR
  265. When starting the named service, if this service is also starting, wait for this service
  266. to finish starting before bringing the named service up. This is largely equivalent to specifying
  267. an \fBafter\fR relationship to this service in the named service (but the relationship "belongs"
  268. to this service and so will be removed if this service is unloaded, for example).
  269. .TP
  270. \fBchain\-to\fR = \fIservice-name\fR
  271. When this service terminates (i.e. starts successfully, and then stops of its
  272. own accord), the named service should be started.
  273. Note that the named service is not loaded until that time; naming an invalid service will
  274. not cause this service to fail to load.
  275. .sp
  276. This can be used for a service that supplies an interactive "recovery mode"
  277. for another service; once the user exits the recovery shell, the primary
  278. service (as named via this setting) will then start.
  279. It also supports multi-stage system startup where later service description files reside on
  280. a separate filesystem that is mounted during the first stage; such service
  281. descriptions will not be found at initial start, and so cannot be started
  282. directly, but can be chained via this directive.
  283. .sp
  284. The chain is not executed if the initial service was explicitly stopped,
  285. stopped due to a dependency stopping (for any reason), if it will restart
  286. (including due to a dependent restarting), or if its process terminates
  287. abnormally or with an exit status indicating an error.
  288. However, if the \fBalways-chain\fR option is set the chain is started regardless of the
  289. reason and the status of this service termination.
  290. .TP
  291. \fBsocket\-listen\fR = \fIsocket-path\fR
  292. Pre-open a socket for the service and pass it to the service using the
  293. \fBsystemd\fR activation protocol.
  294. This by itself does not give so called "socket activation", but does allow any
  295. process trying to connect to the specified socket to do so immediately after
  296. the service is started (even before the service process is properly prepared
  297. to accept connections).
  298. .sp
  299. The path value is subject to variable substitution (see \fBVARIABLE SUBSTITUTION\fR).
  300. .TP
  301. \fBsocket\-permissions\fR = \fIoctal-permissions-mask\fR
  302. Gives the permissions for the socket specified using \fBsocket\-listen\fR.
  303. Normally this will be 600 (user access only), 660 (user and group
  304. access), or 666 (all users).
  305. The default is 666.
  306. .TP
  307. \fBsocket\-uid\fR = {\fInumeric-user-id\fR | \fIusername\fR}
  308. Specifies the user (name or numeric ID) that should own the activation socket.
  309. If \fBsocket\-uid\fR is specified as a name without also specifying \fBsocket-gid\fR, then
  310. the socket group is the primary group of the specified user (as found in the
  311. system user database, normally \fI/etc/passwd\fR).
  312. If the \fBsocket\-uid\fR setting is not provided, the socket will be owned by the user id of the \fBdinit\fR process.
  313. .TP
  314. \fBsocket\-gid\fR = {\fInumeric-group-id\fR | \fIgroup-name\fR}
  315. Specifies the group of the activation socket. See discussion of \fBsocket\-uid\fR.
  316. .TP
  317. \fBterm\-signal\fR = {none | HUP | INT | TERM | QUIT | USR1 | USR2 | KILL}
  318. Specifies the signal to send to the process when requesting it
  319. to terminate (applies to `process' and `bgprocess' services only).
  320. The default is SIGTERM.
  321. See also \fBstop\-timeout\fR.
  322. .TP
  323. \fBready\-notification\fR = {\fBpipefd:\fR\fIfd-number\fR | \fBpipevar:\fR\fIenv-var-name\fR}
  324. Specifies the mechanism, if any, by which a process service will notify that it is ready
  325. (successfully started).
  326. If not specified, a process service is considered started as soon as it has begun execution.
  327. The two options are:
  328. .RS
  329. .IP \(bu
  330. \fBpipefd:\fR\fIfd-number\fR \(em the service will write a message to the specified file descriptor,
  331. which \fBdinit\fR sets up as the write end of a pipe before execution.
  332. This mechanism is compatible with the S6 supervision suite.
  333. .IP \(bu
  334. \fBpipevar:\fR\fIenv-var-name\fR \(em the service will write a message to file descriptor identified
  335. using the contents of the specified environment variable, which will be set by \fBdinit\fR before
  336. execution to a file descriptor (chosen arbitrarily) attached to the write end of a pipe.
  337. .RE
  338. .TP
  339. \fBlogfile\fR = \fIlog-file-path\fR
  340. Specifies the log file for the service.
  341. Output from the service process (standard output and standard error streams) will be appended to this file.
  342. This setting has no effect if the service is set to run on the console (via the \fBruns\-on\-console\fR,
  343. \fBstarts\-on\-console\fR, or \fBshares\-console\fR options).
  344. The value is subject to variable substitution (see \fBVARIABLE SUBSTITUTION\fR).
  345. .TP
  346. \fBoptions\fR = \fIoption\fR...
  347. Specifies various options for this service. See the \fBOPTIONS\fR section.
  348. This directive can be specified multiple times to set additional options.
  349. .TP
  350. \fBload\-options\fR = \fIload_option\fR...
  351. Specifies options for interpreting other settings when loading this service description.
  352. Currently there is only one available option, \fBexport-passwd-vars\fR, which specifies that
  353. the environment variables `\fBUSER\fR', `\fBLOGNAME\fR' (same as `\fBUSER\fR'),
  354. `\fBHOME\fR', `\fBSHELL\fR', `\fBUID\fR', and `\fBGID\fR' should be exported into the
  355. service's load environment (that is, overriding any global environment including the
  356. global environment file, but being overridable by the service's environment file).
  357. .TP
  358. \fBinittab\-id\fR = \fIid-string\fR
  359. When this service is started, if this setting (or the \fBinittab\-line\fR setting) has a
  360. specified value, an entry will be created in the system "utmp" database which tracks
  361. processes and logged-in users.
  362. Typically this database is used by the "who" command to list logged-in users.
  363. The entry will be cleared when the service terminates.
  364. .sp
  365. The \fBinittab\-id\fR setting specifies the "inittab id" to be written in the entry for
  366. the process.
  367. The value is normally quite meaningless.
  368. However, it should be distinct (or unset) for separate processes.
  369. It is typically limited to a very short length.
  370. .sp
  371. The "utmp" database is mostly a historical artifact.
  372. Access to it on some systems is prone to denial-of-service by unprivileged users.
  373. It is therefore recommended that this setting not be used.
  374. However, "who" and similar utilities may not work correctly without this setting
  375. (or \fBinittab\-line\fR) enabled appropriately.
  376. .sp
  377. This setting has no effect if Dinit was not built with support for writing to the "utmp"
  378. database.
  379. .TP
  380. \fBinittab\-line\fR = \fItty-name-string\fR
  381. This specifies the tty line that will be written to the "utmp" database when this service
  382. is started.
  383. Normally, for a terminal login service, it would match the terminal device name on which
  384. the login process runs, without the "/dev/" prefix.
  385. .sp
  386. See the description of the \fBinittab\-id\fR setting for details.
  387. .TP
  388. \fBrlimit\-nofile\fR = \fIresource-limits\fR
  389. Specifies the number of file descriptors that a process may have open simultaneously.
  390. See the \fBRESOURCE LIMITS\fR section.
  391. .TP
  392. \fBrlimit\-core\fR = \fIresource-limits\fR
  393. Specifies the maximum size of the core dump file that will be generated for the process if it
  394. crashes (in a way that would result in a core dump).
  395. See the \fBRESOURCE LIMITS\fR section.
  396. .TP
  397. \fBrlimit\-data\fR = \fIresource-limits\fR
  398. Specifies the maximum size of the data segment for the process, including statically allocated
  399. data and heap allocations.
  400. Precise meaning may vary between operating systems.
  401. See the \fBRESOURCE LIMITS\fR section.
  402. .TP
  403. \fBrlimit\-addrspace\fR = \fIresource-limits\fR
  404. Specifies the maximum size of the address space of the process.
  405. See the \fBRESOURCE LIMITS\fR section.
  406. Note that some operating systems (notably, OpenBSD) do not support this limit; the
  407. setting will be ignored on such systems.
  408. .TP
  409. \fBrun\-in\-cgroup\fR = \fIcgroup-path\fR
  410. Run the service process(es) in the specified cgroup (see \fBcgroups\fR(7)).
  411. The cgroup is specified as a path; if it has a leading slash, the remainder of the path is
  412. interpreted as relative to \fI/sys/fs/cgroup\fR, and otherwise the entire path is interpreted
  413. relative to the cgroup in which \fBdinit\fR is running (as determined at startup or specified
  414. by options).
  415. The latter can only be used if there is only a single cgroup hierarchy (either the cgroups v2
  416. hierarchy with no cgroups v1 hierarchies, or a single cgroups v1 hierarchy).
  417. .sp
  418. Note that due to the "no internal processes" rule in cgroups v2, a relative path must typically
  419. begin with ".." if cgroups v2 are used.
  420. .sp
  421. The named cgroup must already exist prior to the service starting; it will not be created by
  422. \fBdinit\fR.
  423. .sp
  424. This setting is only available if \fBdinit\fR was built with cgroups support.
  425. .\"
  426. .SS OPTIONS
  427. .\"
  428. These options are specified via the \fBoptions\fR parameter.
  429. .\"
  430. .TP
  431. \fBruns\-on\-console\fR
  432. Specifies that this service uses the console; its input and output should be
  433. directed to the console (or precisely, to the device to which Dinit's standard
  434. output stream is connected).
  435. A service running on the console prevents other services from running on the
  436. console (they will queue for the console).
  437. .sp
  438. Proper operation of this option (and related options) assumes that \fBdinit\fR
  439. is itself attached correctly to the console device (or a terminal, in which case
  440. that terminal will be used as the "console").
  441. .sp
  442. The \fIinterrupt\fR key (normally control-C) will be active for process / scripted
  443. services that run on the console.
  444. Handling of an interrupt is determined by the service process, but typically will
  445. cause it to terminate.
  446. .TP
  447. \fBstarts\-on\-console\fR
  448. Specifies that this service uses the console during service startup.
  449. This is identical to \fBruns\-on\-console\fR except that the console will be released
  450. (available for running other services) once the service has started.
  451. It is applicable only for \fBbgprocess\fR and \fBscripted\fR services.
  452. .sp
  453. As for the \fBruns\-on\-console\fR option, the \fIinterrupt\fR key will be enabled
  454. while the service has the console.
  455. .TP
  456. \fBshares\-console\fR
  457. Specifies that this service should be given access to the console (input and output
  458. will be connected to the console), but that it should not exclusively hold the
  459. console. A service given access to the console in this way will not delay the startup of services
  460. which require exclusive access to the console (see \fBstarts\-on\-console\fR,
  461. \fBruns\-on\-console\fR) nor will it be itself delayed if such services are already running.
  462. .sp
  463. This is mutually exclusive with both \fBstarts\-on\-console\fR and \fBruns\-on\-console\fR;
  464. setting this option unsets both those options, and setting either of those options unsets
  465. this option.
  466. .TP
  467. \fBstarts\-rwfs\fR
  468. This service mounts the root filesystem read/write (or at least mounts the
  469. normal writable filesystems for the system).
  470. This prompts Dinit to attempt to create its control socket, if it has not already managed to do so,
  471. and similarly log boot time to the system \fBwtmp\fR(5) database (if supported) if not yet done.
  472. This option may be specified on multiple services, which may be useful if the wtmp database becomes
  473. writable at a different stage than the control socket location becomes writable, for example.
  474. If the control socket has already been created, this option currently causes Dinit to check that
  475. the socket "file" still exists and re-create it if not. It is not recommended to rely on this
  476. behaviour.
  477. .TP
  478. \fBstarts\-log\fR
  479. This service starts the system log daemon.
  480. Dinit will begin logging via the \fI/dev/log\fR socket.
  481. .TP
  482. \fBpass\-cs\-fd\fR
  483. Pass an open Dinit control socket to the process when launching it (the
  484. \fIDINIT_CS_FD\fR environment variable will be set to the file descriptor of
  485. the socket).
  486. This allows the service to issue commands to Dinit even if the regular control socket is not available yet.
  487. .sp
  488. Using this option has security implications! The service which receives the
  489. control socket must close it before launching any untrusted processes.
  490. You should not use this option unless the service is designed to receive a Dinit
  491. control socket.
  492. .TP
  493. \fBstart\-interruptible\fR
  494. This service can have its startup interrupted (cancelled) if it becomes inactive
  495. while still starting, by sending it the SIGINT signal.
  496. This is meaningful only for \fBbgprocess\fR and \fBscripted\fR services.
  497. .TP
  498. \fBskippable\fR
  499. For scripted services, indicates that if the service startup process terminates
  500. via an interrupt signal (SIGINT), then the service should be considered started.
  501. Note that if the interrupt was issued by Dinit to cancel startup, the service
  502. will instead be considered stopped.
  503. .sp
  504. This can be combined with options such as \fBstarts\-on\-console\fR to allow
  505. skipping certain non-essential services (such as filesystem checks) using the
  506. \fIinterrupt\fR key (typically control-C).
  507. .TP
  508. \fBsignal\-process-only\fR
  509. Signal the service process only, rather than its entire process group, whenever
  510. sending it a signal for any reason.
  511. .TP
  512. \fBalways\-chain\fR
  513. Alters behaviour of the \fBchain-to\fR property, forcing the chained service to
  514. always start on termination of this service (instead of only when this service
  515. terminates with an exit status indicating success).
  516. .TP
  517. \fBkill\-all\-on\-stop\fR
  518. Before stopping this service, send a TERM signal and then (after a short pause) a
  519. KILL signal to all other processes in the system, forcibly terminating them.
  520. This option is intended to allow system shutdown scripts to run without any possible
  521. interference from "leftover" or orphaned processes (for example, unmounting file systems usually
  522. requires that the file systems are no longer in use).
  523. .sp
  524. This option must be used with care since the signal broadcast does not discriminate and
  525. potentially kills other services (or their shutdown scripts); a strict dependency ordering
  526. is suggested, i.e. every other service should either be a (possibly transitive) dependency or
  527. dependent of the service with this option set.
  528. .sp
  529. This option can be used for scripted and internal services only.
  530. .RE
  531. .\"
  532. .SS RESOURCE LIMITS
  533. .\"
  534. There are several settings for specifying process resource limits: \fBrlimit\-nofile\fR,
  535. \fBrlimit\-core\fR, \fBrlimit\-data\fR and \fBrlimit\-addrspace\fR.
  536. See the descriptions of each above.
  537. These settings place a limit on resource usage directly by the process.
  538. Note that resource limits are inherited by subprocesses, but that usage of a resource
  539. and subprocess are counted separately (in other words, a process can effectively bypass
  540. its resource limits by spawning a subprocess and allocating further resources within it).
  541. .sp
  542. Resources have both a \fIhard\fR and \fIsoft\fR limit.
  543. The soft limit is the effective limit, but note that a process can raise its soft limit up
  544. to the hard limit for any given resource.
  545. Therefore the soft limit acts more as a sanity-check; a process can exceed the soft limit
  546. only by deliberately raising it first.
  547. .sp
  548. Resource limits are specified in the following format:
  549. .sp
  550. .RS
  551. \fIsoft-limit\fR:\fIhard-limit\fR
  552. .RE
  553. .sp
  554. Either the soft limit or the hard limit can be omitted (in which case it will be unchanged).
  555. A limit can be specified as a dash, `\fB\-\fR', in which case the limit will be removed.
  556. If only one value is specified with no colon separator, it affects both the soft and hard limit.
  557. .\"
  558. .SS VARIABLE SUBSTITUTION
  559. .\"
  560. Some service properties specify a path to a file or directory, or a command line.
  561. For these properties, the specified value may contain one or more environment
  562. variable names, each preceded by a single `\fB$\fR' character, as in `\fB$NAME\fR'.
  563. In each case the value of the named environment variable will be substituted.
  564. The name must begin with a non-punctuation, non-space, non-digit character, and ends
  565. before the first control character, space, or punctuation character other than `\fB_\fR'.
  566. To avoid substitution, a single `\fB$\fR' can be escaped with a second, as in `\fB$$\fR'.
  567. .sp
  568. Note command-line variable substitution occurs after splitting the line into separate arguments and so
  569. a single environment variable cannot be used to add multiple arguments to a command line.
  570. If a designated variable is not defined, it is replaced with an empty (zero-length) string, possibly producing a
  571. zero-length argument.
  572. .sp
  573. Variable substitution also supports a limited subset of shell syntax. You can use curly
  574. braces to enclose the variable, as in `\fB${NAME}\fR'. Limited parameter expansion is
  575. also supported, specifically the forms `\fB${NAME:\-word}\fR' (substitute `\fBword\fR'
  576. if variable is unset or empty), `\fB${NAME\-word}\fR' (substitute `\fBword\fR' if
  577. variable is unset), `\fB${NAME:+word}\fR' (substitute `\fBword\fR' if variable is
  578. set and non\-empty), and `\fB${NAME+word}\fR' (substitute `\fBword\fR' if variable
  579. is set).
  580. .sp
  581. The priority of environment variables, from highest to lowest, is the service \fBenv\-file\fR,
  582. followed by variables set by the \fBset\-passwd\-vars\fR load option, followed by the global
  583. environment file of \fBdinit\fR, followed by the process environment of \fBdinit\fR. This
  584. applies to both the substitutions as well as the process environment of the service.
  585. .\"
  586. .SH EXAMPLES
  587. .LP
  588. Here is an example service description for the \fBmysql\fR database server.
  589. It has a dependency on the \fBrcboot\fR service (not shown) which is
  590. expected to have set up the system to a level suitable for basic operation.
  591. .sp
  592. .RS
  593. .nf
  594. .gcolor blue
  595. .ft CR
  596. # mysqld service
  597. type = process
  598. command = /usr/bin/mysqld --user=mysql
  599. logfile = /var/log/mysqld.log
  600. smooth-recovery = true
  601. restart = false
  602. depends-on = rcboot # Basic system services must be ready
  603. .ft
  604. .gcolor
  605. .RE
  606. .fi
  607. .LP
  608. Here is an examples for a filesystem check "service", run by a script
  609. (\fI/etc/dinit.d/rootfscheck.sh\fR).
  610. The script may need to reboot the system, but the control socket may not have been
  611. created, so it uses the \fBpass-cs-fd\fR option to allow the \fBreboot\fR command
  612. to issue control commands to Dinit.
  613. It runs on the console, so that output is visible and the process can be interrupted
  614. using control-C, in which case the check is skipped but dependent services continue to start.
  615. .sp
  616. .RS
  617. .nf
  618. .gcolor blue
  619. .ft CR
  620. # rootfscheck service
  621. type = scripted
  622. command = /etc/dinit.d/rootfscheck.sh
  623. restart = false
  624. options = starts-on-console pass-cs-fd
  625. options = start-interruptible skippable
  626. depends-on = early-filesystems # /proc and /dev
  627. depends-on = device-node-daemon
  628. .ft
  629. .gcolor
  630. .fi
  631. .RE
  632. .sp
  633. More examples are provided with the Dinit distribution.
  634. .\"
  635. .SH AUTHOR
  636. Dinit, and this manual, were written by Davin McCall.
  637. $$$dnl