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

perpok.8 (5321B)


  1. .\" perpok.8
  2. .\" wcm, 2009.11.10 - 2013.01.09
  3. .\" ===
  4. .TH perpok 8 "January 2013" "perp-2.07" "persistent process supervision"
  5. .SH NAME
  6. perpok \- check a
  7. .BR perpd (8)
  8. service
  9. .SH SYNOPSIS
  10. .B perpok [\-hV] [\-b
  11. .I basedir
  12. .B ] [\-u
  13. .I secs
  14. .B ] [\-v]
  15. .I sv
  16. .SH DESCRIPTION
  17. .B perpok
  18. is used to check that the service
  19. .I sv
  20. is actively running under supervision of
  21. .BR perpd (8).
  22. .PP
  23. The argument
  24. .I sv
  25. should be a service definition directory supervised by
  26. .BR perpd (8).
  27. .B perpok
  28. will look for
  29. .I sv
  30. in the directory given with the
  31. .B \-b
  32. option,
  33. or as set in the
  34. .B PERP_BASE
  35. environmental variable,
  36. or in the current directory if neither of the previous is given.
  37. .PP
  38. .B perpok
  39. returns 0 to indicate success if the definition directory
  40. .I sv
  41. exists and is under the active supervision of
  42. .BR perpd (8).
  43. .PP
  44. The
  45. .B \-u
  46. option may be given to specify a minimum uptime in
  47. .IR secs .
  48. In this case,
  49. .B perpok
  50. will further check that the main service itself is running,
  51. is not resetting,
  52. does not want down,
  53. and that its uptime has been at least
  54. .I secs
  55. seconds.
  56. If all these conditions are met,
  57. .B perpok
  58. returns 0 to indicate success.
  59. .PP
  60. If the conditions for success are not met,
  61. .B perpok
  62. exits non-zero.
  63. .PP
  64. .B perpok
  65. is intended primarily as a utility for boolean testing in scripting environments.
  66. See the
  67. .BR perpstat (8)
  68. and
  69. .BR perpls (8)
  70. utilities for more detailed status reporting.
  71. .SH OPTIONS
  72. .TP
  73. .B \-b basedir
  74. Base directory.
  75. Sets the base directory containing the service definition
  76. .IR sv .
  77. If not set,
  78. .B perpok
  79. will use the value set in the variable PERP_BASE,
  80. or the current directory if neither of these are defined.
  81. On a normal system,
  82. the base directory will be
  83. .IR /etc/perp .
  84. .TP
  85. .B \-h
  86. Help.
  87. Print a brief usage message to stderr and exit.
  88. .TP
  89. .B \-u secs
  90. Uptime.
  91. Normally
  92. .B perpok
  93. checks only that the
  94. .I sv
  95. directory is active (exists and is sticky),
  96. and that
  97. .BR perpd (8)
  98. is actively supervising it.
  99. This option extends the checks performed by
  100. .B perpok
  101. to test that the main service itself is running,
  102. is not resetting,
  103. does not want down,
  104. and that its uptime has been at least
  105. .I secs
  106. seconds.
  107. Normally it is sensible to set
  108. .I secs
  109. to some small value, such as 2 or 3,
  110. which is
  111. just long enough to check that the service is not cycling on restarts.
  112. .TP
  113. .B \-V
  114. Version.
  115. Print the version number to stderr and exit.
  116. .TP
  117. .B \-v
  118. Verbose.
  119. Normally
  120. .B perpok
  121. exits silently,
  122. as it is designed primarily for runscripts that might use it to perform simple dependency checks
  123. prior to starting their own services.
  124. This option causes
  125. .B perpok
  126. to print a message reporting either success or failure to stderr on exit.
  127. .SH EXAMPLES
  128. .B perpok
  129. may be used as a basic dependency checking utility within service runscripts:
  130. .PP
  131. .RS
  132. .nf
  133. #!/bin/sh
  134. if test ${1} = "start" ; then
  135. if ! perpok -u3 foo ; then
  136. echo "dependency foo not running"
  137. exit 1
  138. fi
  139. # otherwise foo ok, continue to start service:
  140. exec /usr/bin/bar ...
  141. fi
  142. .fi
  143. .RE
  144. .PP
  145. This example shows a runscript for a ``bar'' service that uses
  146. .B perpok
  147. to require a dependency on another service named ``foo''.
  148. If foo has not been running for at least 3 seconds,
  149. the runscript exits immediately.
  150. The
  151. .BR perpd (8)
  152. supervisor running this service will then continue to try restarting it at one second intervals,
  153. until the
  154. .B perpok
  155. dependency check succeeds.
  156. .PP
  157. Note that, when using
  158. .B perpok
  159. in a normal collection of services running under
  160. .BR perpd (8),
  161. PERP_BASE will always be properly predefined in the runscript environment.
  162. .PP
  163. .SH EXIT STATUS
  164. .B perpok
  165. exits with the following values:
  166. .TP
  167. 0
  168. Success.
  169. The service
  170. .I sv
  171. is active and a
  172. .BR perpd (8)
  173. supervisor has been found running for it.
  174. Additionally,
  175. if the
  176. .B \-u
  177. option has been given,
  178. the main service itself has been found running,
  179. not resetting,
  180. not wanting down,
  181. and with an uptime of at least
  182. .I secs
  183. seconds.
  184. .TP
  185. 1
  186. Failure.
  187. The service directory
  188. .I sv
  189. was found not to be active,
  190. or a
  191. .BR perpd (8)
  192. supervisor was not found running for it,
  193. or the additional constraints imposed for uptime checking
  194. with the
  195. .B \-u
  196. option were not met.
  197. .TP
  198. 100
  199. Usage error.
  200. For unknown options, missing arguments, or if
  201. .I sv
  202. does not name a directory.
  203. Prints a brief diagnostic message to stderr on exit.
  204. .TP
  205. 111
  206. System error.
  207. Unexpected failures during system calls, privilege and/or resource problems,
  208. or configuration errors in the
  209. .BR perpd (8)
  210. system.
  211. Prints a brief diagnostic message to stderr on exit.
  212. .SH CAVEATS
  213. For use as a dependency tool,
  214. .B perpok
  215. by itself is of course limited.
  216. As illustrated in the example section above,
  217. .B perpok
  218. may find a dependency running okay at startup,
  219. but there is no guarantee that it will continue to run for as long
  220. as the dependent service requires it.
  221. .PP
  222. A collection of services running under
  223. .BR perpd (8)
  224. tends to be reliable,
  225. so that the use of
  226. .B perpok
  227. for basic dependency checking at startup is normally adequate.
  228. Interrelated services may also use
  229. .B perpok
  230. in combination with runscript
  231. .B reset
  232. targets to implement a system of stricter dependency controls.
  233. .SH AUTHOR
  234. Wayne Marshall, http://b0llix.net/perp/
  235. .SH SEE ALSO
  236. .nh
  237. .BR perp_intro (8),
  238. .BR perpboot (8),
  239. .BR perpctl (8),
  240. .BR perpd (8),
  241. .BR perpetrate (5),
  242. .BR perphup (8),
  243. .BR perpls (8),
  244. .BR perpstat (8),
  245. .BR sissylog (8),
  246. .BR tinylog (8)
  247. .\" EOF perpok.8