README.txt 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. Supervisor: A System for Allowing the Control of Process State on UNIX
  2. History
  3. 7/3/2006: updated for version 2.0
  4. 8/30/2006: updated for version 2.1
  5. 3/31/2007: updated for version 2.2
  6. Introduction
  7. The supervisor is a client/server system that allows its users to
  8. control a number of processes on UNIX-like operating systems. It
  9. was inspired by the following:
  10. - It is often inconvenient to need to write "rc.d" scripts for
  11. every single process instance. rc.d scripts are a great
  12. lowest-common-denominator form of process
  13. initialization/autostart/management, but they can be painful to
  14. write and maintain. Additionally, rc.d scripts cannot
  15. automatically restart a crashed process and many programs do not
  16. restart themselves properly on a crash. Supervisord starts
  17. processes as its subprocesses, and can be configured to
  18. automatically restart them on a crash. It can also automatically
  19. be configured to start processes on its own invocation.
  20. - It's often difficult to get accurate up/down status on processes
  21. on UNIX. Pidfiles often lie. Supervisord starts processes as
  22. subprocesses, so it always knows the true up/down status of its
  23. children and can be queried conveniently for this data.
  24. - Users who need to control process state often need only to do
  25. that. They don't want or need full-blown shell access to the
  26. machine on which the processes are running. Supervisorctl allows
  27. a very limited form of access to the machine, essentially
  28. allowing users to see process status and control
  29. supervisord-controlled subprocesses by emitting "stop", "start",
  30. and "restart" commands from a simple shell or web UI.
  31. - Users often need to control processes on many machines.
  32. Supervisor provides a simple, secure, and uniform mechanism for
  33. interactively and automatically controlling processes on groups
  34. of machines.
  35. - Processes which listen on "low" TCP ports often need to be
  36. started and restarted as the root user (a UNIX misfeature). It's
  37. usually the case that it's perfectly fine to allow "normal"
  38. people to stop or restart such a process, but providing them with
  39. shell access is often impractical, and providing them with root
  40. access or sudo access is often impossible. It's also (rightly)
  41. difficult to explain to them why this problem exists. If
  42. supervisord is started as root, it is possible to allow "normal"
  43. users to control such processes without needing to explain the
  44. intricacies of the problem to them.
  45. - Processes often need to be started and stopped in groups,
  46. sometimes even in a "priority order". It's often difficult to
  47. explain to people how to do this. Supervisor allows you to
  48. assign priorities to processes, and allows user to emit commands
  49. via the supervisorctl client like "start all", and "restart all",
  50. which starts them in the preassigned priority order.
  51. Supported Platforms
  52. Supervisor has been tested and is known to run on Linux (Fedora Core
  53. 5, Ubuntu 6), Mac OS X (10.4), and Solaris (10 for Intel) and
  54. FreeBSD 6.1. It will likely work fine on most UNIX systems.
  55. Supervisor will not run at all under any version of Windows.
  56. Supervisor requires Python 2.3 or better.
  57. Installing
  58. Run "python setup.py install", then copy the "sample.conf" file to
  59. /etc/supervisord.conf and modify to your liking. If you'd rather
  60. not put the supervisord.conf file in /etc, you can place it anywhere
  61. and start supervisord and point it at the configuration file via the
  62. -c flag, e.g. "python supervisord.py -c /path/to/sample/conf" or, if
  63. you use the shell script named "supervisord", "supervisord -c
  64. /path/to/sample.conf".
  65. I make reference below to a "$BINDIR" when explaining how to run
  66. supervisord and supervisorctl. This is the "bindir" directory that
  67. your Python installation has been configured with. For example, for
  68. an installation of Python installed via "./configure
  69. --prefix=/usr/local/python; make; make install", $BINDIR would be
  70. "/usr/local/python/bin". Python interpreters on different platforms
  71. use different $BINDIRs. Look at the output of "setup.py install" if
  72. you can't figure out where yours is.
  73. Running Supervisord
  74. To start supervisord, run $BINDIR/supervisord. The resulting
  75. process will daemonize itself and detach from the terminal. It
  76. keeps an operations log at "/tmp/supervisor.log" by default.
  77. You can start supervisord in the foreground by passing the "-n" flag
  78. on its command line. This is useful to debug startup problems.
  79. To change the set of programs controlled by supervisord, edit the
  80. supervisord.conf file and kill -HUP or otherwise restart the
  81. supervisord process. This file has several example program
  82. definitions.
  83. Supervisord accepts a number of command-line overrides. Type
  84. 'supervisord -h' for an overview.
  85. Running Supervisorctl
  86. To start supervisorctl, run $BINDIR/supervisorctl. A shell will
  87. be presented that will allow you to control the processes that are
  88. currently managed by supervisord. Type "help" at the prompt to get
  89. information about the supported commands.
  90. supervisorctl may be invoked with "one time" commands when invoked
  91. with arguments from a command line. An example: "supervisorctl stop
  92. all". If arguments are present on the supervisorctl command-line,
  93. it will prevent the interactive shell from being invoked. Instead,
  94. the command will be executed and supervisorctl will exit.
  95. If supervisorctl is invoked in interactive mode against a
  96. supervisord that requires authentication, you will be asked for
  97. authentication credentials.
  98. Components
  99. Supervisord
  100. The server piece of the supervisor is named "supervisord". It is
  101. responsible for responding to commands from the client process as
  102. well as restarting crashed processes. It is meant to be run as
  103. the root user in most production setups. NOTE: see "Security
  104. Notes" at the end of this document for caveats!
  105. The server process uses a configuration file. This is typically
  106. located in "/etc/supervisord.conf". This configuration file is an
  107. "Windows-INI" style config file. It is important to keep this
  108. file secure via proper filesystem permissions because it may
  109. contain unencrypted usernames and passwords.
  110. Supervisorctl
  111. The command-line client piece of the supervisor is named
  112. "supervisorctl". It provides a shell-like interface to the
  113. features provided by supervisord. From supervisorctl, a user can
  114. connect to different supervisord processes, get status on the
  115. subprocesses controlled by a supervisord, stop and start
  116. subprocesses of a supervisord, and get lists of running processes
  117. of a supervisord.
  118. The command-line client talks to the server across a UNIX domain
  119. socket or an Internet socket. The server can assert that the user
  120. of a client should present authentication credentials before it
  121. allows him to perform commands. The client process may use the
  122. same configuration file as the server; any configuration file with
  123. a [supervisorctl] section in it will work.
  124. Web Server
  125. A (sparse) web user interface with functionality comparable to
  126. supervisorctl may be accessed via a browser if you start
  127. supervisord against an internet socket. Visit the server URL
  128. (e.g. http://localhost:9001/) to view and control process status
  129. through the web interface after changing the configuration file's
  130. 'http_port' parameter appropriately.
  131. XML-RPC Interface
  132. The same HTTP server which serves the web UI serves up an XML-RPC
  133. interface that can be used to interrogate and control supervisor
  134. and the programs it runs. To use the XML-RPC interface, connect
  135. to supervisor's http port with any XML-RPC client library and run
  136. commands against it. An example of doing this using Python's
  137. xmlrpclib client library::
  138. import xmlrpclib
  139. server = xmlrpclib.Server('http://localhost:9001')
  140. Call methods against the supervisor and its subprocesses by using
  141. the 'supervisor' namespace::
  142. server.supervisor.getState()
  143. You can get a list of methods supported by supervisor's XML-RPC
  144. interface by using the XML-RPC 'system.listMethods' API:
  145. server.system.listMethods()
  146. You can see help on a method by using the 'system.methodHelp' API
  147. against the method::
  148. print server.system.methodHelp('supervisor.shutdown')
  149. Supervisor's XML-RPC interface also supports the nascent XML-RPC
  150. multicall API described at
  151. http://www.xmlrpc.com/discuss/msgReader$1208.
  152. You can extend supervisor functionality with new XML-RPC API
  153. methods by adding new top-level RPC interfaces as necessary. See
  154. "Configuration File ['rpcinterface:x] Section Settings" in this
  155. file.
  156. Configuration File '[supervisord]' Section Settings
  157. The supervisord.conf log file contains a section named
  158. '[supervisord]' in which global settings for the supervisord process
  159. should be inserted. These are:
  160. 'http_port' -- Either a TCP host:port value or (e.g. 127.0.0.1:9001)
  161. or a path to a UNIX domain socket (e.g. /tmp/supervisord.sock) on
  162. which supervisor will listen for HTTP/XML-RPC requests.
  163. Supervisorctl itself uses XML-RPC to communicate with supervisord
  164. over this port.
  165. 'sockchmod' -- Change the UNIX permission mode bits of the http_port
  166. UNIX domain socket to this value (ignored if using a TCP socket).
  167. Default: 0700.
  168. 'sockchown' -- Change the user and group of the socket file to this
  169. value. May be a username (e.g. chrism) or a username and group
  170. separated by a dot (e.g. chrism.wheel) Default: do not change.
  171. 'umask' -- The umask of the supervisord process. Default: 022.
  172. 'logfile' -- The path to the activity log of the supervisord process.
  173. 'logfile_maxbytes' -- The maximum number of bytes that may be
  174. consumed by the activity log file before it is rotated (suffix
  175. multipliers like "KB", "MB", and "GB" can be used in the value).
  176. Set this value to 0 to indicate an unlimited log size. Default:
  177. 50MB.
  178. 'logfile_backups' -- The number of backups to keep around resulting
  179. from activity log file rotation. Set this to 0 to indicate an
  180. unlimited number of backups. Default: 10.
  181. 'loglevel' -- The logging level, dictating what is written to the
  182. activity log. One of 'critical', 'error', 'warn', 'info', 'debug'
  183. or 'trace'. At log level 'trace', the supervisord log file will
  184. record the stderr/stdout output of its child processes, which is
  185. useful for debugging. Default: info.
  186. 'pidfile' -- The location in which supervisord keeps its pid file.
  187. 'nodaemon' -- If true, supervisord will start in the foreground
  188. instead of daemonizing. Default: false.
  189. 'minfds' -- The minimum number of file descriptors that must be
  190. available before supervisord will start successfully. Default:
  191. 1024.
  192. 'minprocs' -- The minimum nymber of process descriptors that must be
  193. available before supervisord will start successfully. Default: 200.
  194. 'nocleanup' -- prevent supervisord from clearing old "AUTO" log
  195. files at startup time. Default: false.
  196. 'http_username' -- the username required for authentication to our
  197. HTTP server. Default: none.
  198. 'http_password' -- the password required for authentication to our
  199. HTTP server. Default: none.
  200. 'childlogdir' -- the directory used for AUTO log files. Default:
  201. value of Python's tempfile.get_tempdir().
  202. 'user' -- if supervisord is run as root, switch users to this UNIX
  203. user account before doing any meaningful processing. This value has
  204. no effect if supervisord is not run as root. Default: do not switch
  205. users.
  206. 'directory' -- When supervisord daemonizes, switch to this
  207. directory. Default: do not cd.
  208. 'environment' -- A list of key/value pairs in the form
  209. "KEY=val,KEY2=val2" that will be placed in the supervisord process'
  210. environment (and as a result in all of its child process'
  211. environments). Default: none. **Note** that subprocesses will
  212. inherit the environment variables of the shell used to start
  213. "supervisord" except for the ones overridden here and within the
  214. program's "environment" configuration stanza. See "Subprocess
  215. Environment" below.
  216. Configuration File '[supervisorctl]' Section Settings
  217. The configuration file may contain settings for the supervisorctl
  218. interactive shell program. These options are listed below.
  219. 'serverurl' -- The URL that should be used to access the supervisord
  220. server, e.g. "http://localhost:9001". For UNIX domain sockets, use
  221. "unix:///absolute/path/to/file.sock".
  222. 'username' -- The username to pass to the supervisord server for use
  223. in authentication (should be same as 'http_username' in supervisord
  224. config). Optional.
  225. 'password' -- The password to pass to the supervisord server for use
  226. in authentication (should be the same as 'http_password' in
  227. supervisord config). Optional.
  228. 'prompt' -- String used as supervisorctl prompt. Default: supervisor.
  229. Configuration File '[program:x]' Section Settings
  230. The .INI file must contain one or more 'program' sections in order
  231. for supervisord to know which programs it should start and control.
  232. A sample program section has the following structure, the options of
  233. which are described below it::
  234. [program:programname]
  235. command=/path/to/programname
  236. priority=1
  237. autostart=true
  238. autorestart=true
  239. startsecs=1
  240. startretries=3
  241. exitcodes=0,2
  242. stopsignal=TERM
  243. stopwaitsecs=10
  244. user=nobody
  245. log_stdout=true
  246. log_stderr=false
  247. logfile=/tmp/programname.log
  248. logfile_maxbytes=10MB
  249. logfile_backups=2
  250. environment=A=1,B=2
  251. '[program:programname]' -- the section header, required for each
  252. program. 'programname' is a descriptive name (arbitrary) used to
  253. describe the program being run.
  254. 'command' -- the command that will be run when this program is
  255. started. The command can be either absolute,
  256. e.g. ('/path/to/programname') or relative ('programname'). If it is
  257. relative, the PATH will be searched for the executable. Programs
  258. can accept arguments, e.g. ('/path/to/program foo bar'). The
  259. command line can used double quotes to group arguments with spaces
  260. in them to pass to the program, e.g. ('/path/to/program/name -p "foo
  261. bar"'). Controlled programs should themselves not be daemons, as
  262. supervisord assumes it is responsible for daemonizing its
  263. subprocesses.
  264. 'priority' -- the relative priority of the program in the start and
  265. shutdown ordering. Lower priorities indicate programs that start
  266. first and shut down last at startup and when aggregate commands are
  267. used in various clients (e.g. "start all"/"stop all"). Higher
  268. priorities indicate programs that start last and shut down first.
  269. Default: 999.
  270. 'autostart' -- If true, this program will start automatically when
  271. supervisord is started. Default: true.
  272. 'autorestart' -- If true, when the program exits "unexpectedly",
  273. supervisor will restart it automatically. "unexpected" exits are
  274. those which happen when the program exits with an "unexpected" exit
  275. code (see 'exitcodes'). Default: true.
  276. 'startsecs' -- The total number of seconds which the program needs
  277. to stay running after a startup to consider the start successful.
  278. If the program does not stay up for this many seconds after it is
  279. started, even if it exits with an "expected" exit code, the startup
  280. will be considered a failure. Set to 0 to indicate that the program
  281. needn't stay running for any particular amount of time. Default: 1
  282. 'startretries' -- The number of serial failure attempts that
  283. supervisord will allow when attempting to start the program before
  284. giving up and puting the process into an ERROR state. Default: 3.
  285. 'exitcodes' -- The list of 'expected' exit codes for this program.
  286. A program is considered 'failed' (and will be restarted, if
  287. autorestart is set true) if it exits with an exit code which is not
  288. in this list and a stop of the program has not been explicitly
  289. requested. Default: 0,2.
  290. 'stopsignal' -- The signal used to kill the program when a stop is
  291. requested. This can be any of TERM, HUP, INT, QUIT, KILL, USR1, or
  292. USR2. Default: TERM.
  293. 'stopwaitsecs' -- The number of seconds to wait for the program to
  294. return a SIGCHILD to supervisord after the program has been sent a
  295. stopsignal. If this number of seconds elapses before supervisord
  296. receives a SIGCHILD from the process, supervisord will attempt to
  297. kill it with a final SIGKILL. Default: 10.
  298. 'user' -- If supervisord is running as root, this UNIX user account
  299. will be used as the account which runs the program. If supervisord
  300. is not running as root, this option has no effect. Defaut: do not
  301. switch users.
  302. 'log_stdout' -- Send process stdout output to the process logfile.
  303. Default: true.
  304. 'log_stderr' -- Send process stderr output to the process logfile.
  305. Default: false.
  306. 'logfile' -- Keep process output as determined by log_stdout and
  307. log_stderr in this file. NOTE: if both log_stderr and log_stdout
  308. are true, chunks of output from the process' stderr and stdout will
  309. be intermingled more or less randomly in the log. If 'logfile' is
  310. unset or set to 'AUTO', supervisor will automatically choose a file
  311. location. If this is set to 'NONE', supervisord will create no log
  312. file. AUTO log files and their backups will be deleted when
  313. supervisord restarts. Default: AUTO.
  314. 'logfile_maxbytes' -- The maximum number of bytes that may be
  315. consumed by the process log file before it is rotated (suffix
  316. multipliers like "KB", "MB", and "GB" can be used in the value).
  317. Set this value to 0 to indicate an unlimited log size. Default:
  318. 50MB.
  319. 'logfile_backups' -- The number of backups to keep around resulting
  320. from process log file rotation. Set this to 0 to indicate an
  321. unlimited number of backups. Default: 10.
  322. 'environment' -- A list of key/value pairs in the form
  323. "KEY=val,KEY2=val2" that will be placed in the child process'
  324. environment. Default: none. **Note** that the subprocess will
  325. inherit the environment variables of the shell used to start
  326. "supervisord" except for the ones overridden here. See "Subprocess
  327. Environment" below.
  328. Configuration File '[rpcinterface:x]' Section Settings (ADVANCED)
  329. Changing "rpcinterface:x" settings in the configuration file is only
  330. useful for people who wish to extend supervisor with additional
  331. behavior.
  332. In the sample config file, there is a section which is named
  333. "rpcinterface:supervisor". By default it looks like this:
  334. [rpcinterface:supervisor]
  335. supervisor.rpcinterface_factory = supervisor.xmlrpc:make_main_rpcinterface
  336. This section must remain in the configuration for the standard setup
  337. of supervisor to work properly. If you don't want supervisor to do
  338. anything it doesn't already do out of the box, this is all you need
  339. to know about this type of section.
  340. However, if you wish to add rpc interface namespaces to a custom
  341. version of supervisor, you may add additional [rpcinterface:foo]
  342. sections, where "foo" represents the namespace of the interface
  343. (from the web root), and the value named by
  344. "supervisor.rpcinterface_factory" is a factory callable which should
  345. have a function signature that accepts a single positional argument
  346. "supervisord" and as many keyword arguments as required to perform
  347. configuration. Any key/value pairs defined within the
  348. rpcinterface:foo section will be passed as keyword arguments to the
  349. factory. Here's an example of a factory function, created in the
  350. package "my.package"::
  351. def make_another_rpcinterface(supervisord, **config):
  352. retries = int(config.get('retries', 0))
  353. another_rpc_interface = AnotherRPCInterface(supervisord, retries)
  354. return another_rpc_interface
  355. And a section in the config file meant to configure
  356. it::
  357. [rpcinterface:another]
  358. supervisor.rpcinterface_factory = my.package:make_another_rpcinterface
  359. retries = 1
  360. Nondaemonizing of Subprocesses
  361. Programs run under supervisor *should not* daemonize themselves.
  362. Instead, they should run in the foreground and not detach from the
  363. "terminal" that starts them. The easiest way to tell if a command
  364. will run in the foreground is to run the command from a shell
  365. prompt. If it gives you control of the terminal back, it's
  366. daemonizing itself and that will be the wrong way to run it under
  367. supervisor. You want to run a command that essentially requires you
  368. to press Ctrl-C to get control of the terminal back. If it gives
  369. you a shell prompt back after running it without needing to press
  370. Ctrl-C, it's not useful under supervisor. All programs have options
  371. to be run in the foreground but there's no standard way to do it;
  372. you'll need to read the documentation for each program you want to
  373. do this with.
  374. Subprocess Environment
  375. Subprocesses will inherit the environment of the shell used to start
  376. the supervisord program. These environment variables may be
  377. overridden within the "environment" global config option (applies to
  378. all subprocesses) or within the per-program "environment" config
  379. option (applies only to the subprocess specified within the
  380. "program" section). These "environment" settings are additive. In
  381. other words, each subprocess' environment will consist of::
  382. The environment variables set within the shell used to start
  383. supervisord...
  384. ... added-to/overridden-by ...
  385. ... the environment variables set within the "environment" global
  386. config option ...
  387. ... added-to/overridden-by ...
  388. .. the environment variables set within the per-process
  389. "environment" config option.
  390. No shell is executed by supervisord when it runs a subprocess, so
  391. settings such as USER, PATH, HOME, SHELL, LOGNAME, etc. are not
  392. changed from their defaults or otherwise reassigned. This is
  393. particularly important to note when you are running a program from a
  394. supervisord run as root with a "user=" stanza in the configuration.
  395. Unlike cron, supervisord does not attempt to divine and override
  396. "fundamental" environment variables like USER, PATH, HOME, and
  397. LOGNAME when it performs a setuid to the user defined within the
  398. "user=" program config option. If you need to set environment
  399. variables for a particular program that might otherwise be set by a
  400. shell invocation for a particular user, you must do it explicitly
  401. within the "environment=" program config option. For example::
  402. [program:apache]
  403. command=/home/chrism/bin/httpd -DNO_DETACH
  404. user=chrism
  405. environment=HOME=/home/chrism,USER=chrism
  406. Examples of Program Configurations
  407. Apache 2.0.54::
  408. [program:apache]
  409. command=/usr/sbin/httpd -DNO_DETACH
  410. Postgres 8.14::
  411. [program:postgres]
  412. command=/path/to/postmaster
  413. ; we use the "fast" shutdown signal SIGINT
  414. stopsignal=INT
  415. log_stderr=true
  416. Zope 2.8 instances and ZEO::
  417. [program:zeo]
  418. command=/path/to/runzeo
  419. priority=1
  420. [program:zope1]
  421. command=/path/to/instance/home/bin/runzope
  422. priority=2
  423. log_stderr=true
  424. [program:zope2]
  425. command=/path/to/another/instance/home/bin/runzope
  426. priority=2
  427. log_stderr=true
  428. OpenLDAP slapd::
  429. [program:slapd]
  430. command=/path/to/slapd -f /path/to/slapd.conf -h ldap://0.0.0.0:8888
  431. Process States
  432. A process controlled by supervisord will be in one of the below
  433. states at any given time. You may see these state names in various
  434. user interface elements.
  435. STOPPED (0) -- The process has been stopped due to a stop request or
  436. has never been started.
  437. STARTING (10) -- The process is starting due to a start request.
  438. RUNNING (20) -- The process is running.
  439. BACKOFF (30) -- The process is waiting to restart after a nonfatal error.
  440. STOPPING (40) -- The process is stopping due to a stop request.
  441. EXITED (100) -- The process exited with an expected exit code.
  442. FATAL (200) -- The process could not be started successfully.
  443. UNKNOWN (1000) -- The process is in an unknown state (programming error).
  444. Process progress through these states as per the following directed
  445. graph::
  446. --> STOPPED
  447. / |
  448. | |
  449. | |
  450. STOPPING |
  451. ^ V
  452. | STARTING <-----> BACKOFF
  453. | / ^ |
  454. | V | |
  455. \-- RUNNING / \ |
  456. | / \ V
  457. V / \ ----- FATAL
  458. EXITED
  459. A process is in the STOPPED state if it has been stopped
  460. adminstratively or if it has never been started.
  461. When an autorestarting process is in the BACKOFF state, it will be
  462. automatically restarted by supervisord. It will switch between
  463. STARTING and BACKOFF states until it becomes evident that it cannot
  464. be started because the number of startretries has exceeded the
  465. maximum, at which point it will transition to the FATAL state. Each
  466. start retry will take progressively more time.
  467. An autorestarted process will never be automtatically restarted if
  468. it ends up in the FATAL state (it must be manually restarted from
  469. this state).
  470. A process transitions into the STOPPING state via an administrative
  471. stop request, and will then end up in the STOPPED state.
  472. A process that cannot be stopped successfully will stay in the
  473. STOPPING state forever. This situation should never be reached
  474. during normal operations as it implies that the process did not
  475. respond to a final SIGKILL, which is "impossible" under UNIX.
  476. State transitions which always require user action to invoke are
  477. these:
  478. FATAL -> STARTING
  479. RUNNING -> STOPPING
  480. State transitions which typically, but not always, require user
  481. action to invoke are these, with exceptions noted:
  482. STOPPED -> STARTING (except at supervisord startup if process is
  483. configured to autostart)
  484. EXITED -> STARTING (except if process is configured to autorestart)
  485. All other state transitions are managed by supervisord
  486. automatically.
  487. Signals
  488. Killing supervisord with SIGHUP will stop all processes, reload the
  489. configuration from the config file, and restart all processes.
  490. Killing supervisord with SIGUSR2 will close and reopen the
  491. supervisord activity log and child log files.
  492. Access Control
  493. The UNIX permissions on the socket effectively control who may send
  494. commands to the server. HTTP basic authentication provides access
  495. control for internet and UNIX domain sockets as necessary.
  496. Security Notes
  497. I have done my best to assure that use of a supervisord process
  498. running as root cannot lead to unintended privilege escalation, but
  499. caveat emptor. Particularly, it is not as paranoid as something
  500. like DJ Bernstein's "daemontools", inasmuch as "supervisord" allows
  501. for arbitrary path specifications in its configuration file to which
  502. data may be written. Allowing arbitrary path selections can create
  503. vulnerabilities from symlink attacks. Be careful when specifying
  504. paths in your configuration. Ensure that supervisord's
  505. configuration file cannot be read from or written to by unprivileged
  506. users and that all files installed by the supervisor package have
  507. "sane" file permission protection settings. Additionally, ensure
  508. that your PYTHONPATH is sane and that all Python standard library
  509. files have adequate file permission protections. Then, pray to the
  510. deity of your choice.
  511. Other Notes
  512. Some examples of shell scripts to start services under supervisor
  513. can be found "here":http://www.thedjbway.org/services.html. These
  514. examples are actually for daemontools but the premise is the same
  515. for supervisor. Another collection of recipes for starting various
  516. programs in the foreground is
  517. "here":http://smarden.org/runit/runscripts.html .
  518. Some processes (like mysqld) ignore signals sent to the actual
  519. process/thread which is created by supervisord. Instead, a
  520. "special" thread/process is created by these kinds of programs which
  521. is responsible for handling signals. This is problematic, because
  522. supervisord can only kill a pid which it creates itself, not any
  523. child thread or process of the program it creates. Fortunately,
  524. these programs typically write a pidfile which is meant to be read
  525. in order to kill the process. As a workaround for this case, a
  526. special "pidproxy" program can handle startup of these kinds of
  527. processes. The pidproxy program is a small shim that starts a
  528. process, and upon the receipt of a signal, sends the signal to the
  529. pid provided in a pidfile. A sample supervisord configuration
  530. program entry for a pidproxy-enabled program is provided here::
  531. [program:mysql]
  532. command=/path/to/pidproxy /path/to/pidfile /path/to/mysqld_safe
  533. The pidproxy program is named 'pidproxy.py' and is in the
  534. distribution.
  535. FAQ
  536. My program never starts and supervisor doesn't indicate any error:
  537. Make sure the "x" bit is set on the executable file you're using in
  538. the command= line.
  539. How can I tell if my program is running under supervisor? Supervisor
  540. and its subprocesses share an environment variable
  541. "SUPERVISOR_ENABLED". When a process is run under supervisor, your
  542. program can check for the presence of this variable to determine
  543. whether it is running under supervisor (new in 2.0).
  544. My command line works fine when I invoke it by hand from a shell
  545. prompt, but when I use the same command line in a supervisor
  546. "command=" section, the program fails mysteriously. Why? This may
  547. be due to your process' dependence on environment variable settings.
  548. See "Subprocess Environment" in this document.
  549. Reporting Bugs
  550. Please report bugs at http://www.plope.com/software/collector .
  551. Author Information
  552. Chris McDonough (chrism@plope.com)
  553. http://www.plope.com