dinit-service.5.m4 28 KB

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