logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

perpboot.8 (6643B)


  1. .\" perpboot.8
  2. .\" wcm, 2009.11.30 - 2011.02.01
  3. .\" ===
  4. .TH perpboot 8 "January 2013" "perp-2.07" "persistent process supervision"
  5. .SH NAME
  6. perpboot \- startup utility for
  7. .BR perpd (8)
  8. and an associated logger
  9. .SH SYNOPSIS
  10. .B perpboot [\-hV] [\-dx] [
  11. .I basedir
  12. .B ]
  13. .SH DESCRIPTION
  14. .B perpboot
  15. is a utility for starting and monitoring a
  16. .BR perpd (8)
  17. instance on
  18. .I basedir
  19. with an associated logger.
  20. If
  21. .I basedir
  22. is not specified,
  23. .B perpboot
  24. will use the environmental variable PERP_BASE.
  25. If PERP_BASE is not set or empty,
  26. .B perpboot
  27. will use a compiled-in value for
  28. .IR basedir ,
  29. normally
  30. .IR /etc/perp .
  31. .PP
  32. Within
  33. .IR basedir ,
  34. .B perpboot
  35. switches into a subdirectory named
  36. .IR .boot/ .
  37. It then forks two child processes to exec
  38. .I ./rc.log
  39. and
  40. .IR ./rc.perp ,
  41. with a pipe connected between their respective stdin and stdout.
  42. .PP
  43. Normally
  44. .I ./rc.log
  45. will be an executable script that execs into a stdin logger,
  46. such as
  47. .BR tinylog (8)
  48. or
  49. .BR sissylog (8).
  50. Similarly,
  51. .I ./rc.perp
  52. will be an executable script that ultimately execs into
  53. .BR perpd (8).
  54. See the examples section below for sample scripts.
  55. .PP
  56. .B perpboot
  57. sets up its
  58. .I ./rc.log
  59. and
  60. .I ./rc.perp
  61. child processes with an environment that:
  62. .RS
  63. .IP \(bu 4
  64. closes all extraneous file descriptors
  65. .IP \(bu 4
  66. redirects unused stdin, stdout, and stderr to
  67. .I /dev/null
  68. .IP \(bu 4
  69. redirects the stdin of
  70. .I ./rc.log
  71. to the stdout of
  72. .I ./rc.perp
  73. (and vice versa)
  74. .IP \(bu 4
  75. redirects the stderr of
  76. .I ./rc.perp
  77. to stdout (with the effect that both stdout and stderr of
  78. .I ./rc.perp
  79. are captured by the logger)
  80. .IP \(bu 4
  81. sets the environmental variable PERP_BASE to the value used for
  82. .I basedir
  83. .RE
  84. .PP
  85. By default,
  86. .B perpboot
  87. itself acts as lightweight supervisor for the
  88. .I ./rc.log
  89. and
  90. .I ./rc.perp
  91. child processes.
  92. If
  93. .B perpboot
  94. notices that either of these processes has died,
  95. it will try to restart them.
  96. .SH OPTIONS
  97. .TP
  98. .B \-d
  99. Detach.
  100. Normally
  101. .B perpboot
  102. itself runs in the foreground.
  103. The
  104. .B \-d
  105. option causes
  106. .B perpboot
  107. to detach from the controlling terminal and run as a background process.
  108. This option is useful when starting
  109. .B perpboot
  110. from within a BSD-type boot script
  111. such as
  112. .IR rc.local .
  113. .TP
  114. .B \-h
  115. Help.
  116. Print a brief usage message to stderr and exit.
  117. .TP
  118. .B \-V
  119. Version.
  120. Print the version number to stderr and exit.
  121. .TP
  122. .B \-x
  123. Exit.
  124. Normally
  125. .B perpboot
  126. stays resident as a system process that monitors its
  127. .I ./rc.log
  128. and
  129. .I ./rc.perp
  130. child processes.
  131. The
  132. .B \-x
  133. option causes
  134. .B perpboot
  135. to start
  136. .I ./rc.log
  137. and then replace itself with the
  138. .I ./rc.perp
  139. process.
  140. This option is used to reduce process overhead
  141. and/or when you don't feel the need to retain
  142. .B perpboot
  143. as a supervisor.
  144. As one example,
  145. this option might be used within an
  146. .BR inittab (5)
  147. specification configured with the
  148. .I action
  149. specified as ``respawn''.
  150. .SH EXAMPLES
  151. An example
  152. .I ./rc.log
  153. script may look like this:
  154. .PP
  155. .RS
  156. .nf
  157. #!/bin/sh
  158. LOGDIR=/var/log/perpd
  159. exec tinylog -k 8 -s 100000 -t ${LOGDIR}
  160. .fi
  161. .RE
  162. .PP
  163. This script execs into an instance of
  164. .BR tinylog (8)
  165. maintaining a rotated set of log files in
  166. .I /var/log/perpd
  167. with a maximum of 8 keep files,
  168. a maximum log size of 100000 bytes,
  169. and with timestamp prepended entries.
  170. .PP
  171. An example
  172. .I ./rc.perp
  173. script:
  174. .PP
  175. .RS
  176. .nf
  177. #!/bin/sh
  178. exec perpd -a 6 $PERP_BASE
  179. .fi
  180. .RE
  181. .PP
  182. Here the script execs into
  183. .BR perpd (8)
  184. with autoscanning set to 6 seconds.
  185. Note also that the environmental variable PERP_BASE is defined and available for the
  186. .I ./rc.perp
  187. and
  188. .I ./rc.log
  189. scripts.
  190. .PP
  191. These simple scripts could be customized and embellished considerably.
  192. For example, the
  193. .I ./rc.log
  194. script could:
  195. .RS
  196. .IP \(bu 4
  197. check/create existence/permissions of log directory
  198. .IP \(bu 4
  199. drop privilege before running
  200. .BR tinylog (8)
  201. \-\- see
  202. .BR runuid (8)
  203. .RE
  204. .PP
  205. Similarly, the
  206. .I ./rc.perp
  207. script could perform other initializations before the
  208. .BR perpd (8)
  209. exec:
  210. .RS
  211. .IP \(bu 4
  212. check/create existence and symlink for
  213. .I /etc/perp/.control
  214. .IP \(bu 4
  215. clean out stale control directories/files in
  216. .I /etc/perp/.control
  217. .RE
  218. .PP
  219. .B perpd
  220. itself may be invoked in the way that best suits the
  221. .BR init (8)
  222. system and boot scripts of the host environment.
  223. A sysv-compatible system may use an
  224. .BR inittab (5)
  225. file configured with this entry:
  226. .PP
  227. .RS
  228. .nf
  229. PB:23456:respawn:/usr/sbin/perpboot -x /etc/perp
  230. .fi
  231. .RE
  232. .PP
  233. This example shows the
  234. .B \-x
  235. option,
  236. with the effect that
  237. .BR init (8)
  238. itself will monitor the
  239. .BR perpd (8)
  240. process and respawn it if it dies.
  241. .PP
  242. A BSD-type system may use an
  243. .I rc.local
  244. file with this entry:
  245. .PP
  246. .RS
  247. .nf
  248. if [ -x /usr/sbin/perpboot ]; then
  249. echo -n ' perpd'
  250. /usr/sbin/runenv -i /etc/perp/.boot/perp.env \\\^
  251. /usr/sbin/perpboot -d /etc/perp
  252. fi
  253. .fi
  254. .RE
  255. .PP
  256. In this example, the
  257. .B \-d
  258. option is used to run
  259. .B perpboot
  260. as a daemon process.
  261. .PP
  262. This example is further embellished to show the use of the
  263. .BR runenv (8)
  264. runtool to setup a clean environment for the
  265. .BR perpd (8)
  266. process and its children.
  267. .SH FILES
  268. .I /etc/perp/
  269. .RS
  270. The default base operating directory for
  271. .BR perpd (8).
  272. .RE
  273. .PP
  274. .I /etc/perp/.boot/
  275. .RS
  276. Directory containing the startup scripts used by
  277. .BR perpboot .
  278. .RE
  279. .PP
  280. .I /etc/perp/.boot/rc.log
  281. .RS
  282. Control script used by
  283. .B perpboot
  284. to start a logger for
  285. .BR perpd (8).
  286. .RE
  287. .PP
  288. .I /etc/perp/.boot/rc.perp
  289. .RS
  290. Control script used by
  291. .B perpboot
  292. to start up
  293. .BR perpd (8).
  294. .RE
  295. .SH ENVIRONMENT
  296. PERP_BASE
  297. .RS
  298. If no
  299. .I basedir
  300. argument is given at the command-line on startup,
  301. .B perpboot
  302. checks for a value defined by PERP_BOOT.
  303. If this is not defined or empty,
  304. .B perpboot
  305. uses a compiled-in default, normally
  306. .IR /etc/perp .
  307. .SH SIGNALS
  308. If
  309. .B perpboot
  310. gets the SIGTERM signal,
  311. it performs a shutdown sequence on its child processes:
  312. .RS
  313. .IP \(bu 4
  314. sends SIGTERM and SIGCONT to the
  315. .I ./rc.perp
  316. process and waits for it to terminate
  317. .IP \(bu 4
  318. closes its own copy of the input pipe to the
  319. .I ./rc.log
  320. process and waits for the logger to terminate
  321. .IP \(bu 4
  322. exits 0
  323. .RE
  324. .PP
  325. Otherwise, when
  326. .B perpboot
  327. runs as a lightweight supervisor
  328. (without the
  329. .B \-x
  330. option),
  331. it traps all the other signals it can and relays them directly to the
  332. .I ./rc.perp
  333. child process with
  334. .BR kill (2).
  335. .SH NOTES
  336. The
  337. .B perpboot
  338. utility is a purpose-specific modification of
  339. .BR rundeux (8).
  340. .SH AUTHOR
  341. Wayne Marshall, http://b0llix.net/perp/
  342. .SH SEE ALSO
  343. See the
  344. .BR perp-setup (8)
  345. utility for an ``automagic'' configuration of a
  346. .B perpboot
  347. installation.
  348. .PP
  349. .nh
  350. .BR perp_intro (8),
  351. .BR perp-setup (8),
  352. .BR perpctl (8),
  353. .BR perpd (8),
  354. .BR perpetrate (5),
  355. .BR perphup (8),
  356. .BR perpls (8),
  357. .BR perpok (8),
  358. .BR perpstat (8),
  359. .BR sissylog (8),
  360. .BR tinylog (8),
  361. .BR rundeux (8)
  362. .\" EOF perpboot.8