introduction.rst 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. Introduction
  2. ============
  3. Overview
  4. --------
  5. Supervisor is a client/server system that allows its users to control
  6. a number of processes on UNIX-like operating systems. It was inspired
  7. by the following:
  8. Convenience
  9. It is often inconvenient to need to write ``rc.d`` scripts for every
  10. single process instance. ``rc.d`` scripts are a great
  11. lowest-common-denominator form of process
  12. initialization/autostart/management, but they can be painful to
  13. write and maintain. Additionally, ``rc.d`` scripts cannot
  14. automatically restart a crashed process and many programs do not
  15. restart themselves properly on a crash. Supervisord starts
  16. processes as its subprocesses, and can be configured to
  17. automatically restart them on a crash. It can also automatically be
  18. configured to start processes on its own invocation.
  19. Accuracy
  20. It's often difficult to get accurate up/down status on processes on
  21. 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. Delegation
  25. Users who need to control process state often need only to do that.
  26. They don't want or need full-blown shell access to the machine on
  27. which the processes are running. Processes which listen on "low"
  28. TCP ports often need to be started and restarted as the root user (a
  29. UNIX misfeature). It's usually the case that it's perfectly fine to
  30. allow "normal" people to stop or restart such a process, but
  31. providing them with shell access is often impractical, and providing
  32. them with root access or sudo access is often impossible. It's also
  33. (rightly) difficult to explain to them why this problem exists. If
  34. supervisord is started as root, it is possible to allow "normal"
  35. users to control such processes without needing to explain the
  36. intricacies of the problem to them. Supervisorctl allows a very
  37. limited form of access to the machine, essentially allowing users to
  38. see process status and control supervisord-controlled subprocesses
  39. by emitting "stop", "start", and "restart" commands from a simple
  40. shell or web UI.
  41. Process Groups
  42. Processes often need to be started and stopped in groups, sometimes
  43. even in a "priority order". It's often difficult to explain to
  44. people how to do this. Supervisor allows you to assign priorities
  45. to processes, and allows user to emit commands via the supervisorctl
  46. client like "start all", and "restart all", which starts them in the
  47. preassigned priority order. Additionally, processes can be grouped
  48. into "process groups" and a set of logically related processes can
  49. be stopped and started as a unit.
  50. Features
  51. --------
  52. Simple
  53. Supervisor is configured through a simple INI-style config file
  54. that’s easy to learn. It provides many per-process options that make
  55. your life easier like restarting failed processes and automatic log
  56. rotation.
  57. Centralized
  58. Supervisor provides you with one place to start, stop, and monitor
  59. your processes. Processes can be controlled individually or in
  60. groups. You can configure Supervisor to provide a local or remote
  61. command line and web interface.
  62. Efficient
  63. Supervisor starts its subprocesses via fork/exec and subprocesses
  64. don’t daemonize. The operating system signals Supervisor immediately
  65. when a process terminates, unlike some solutions that rely on
  66. troublesome PID files and periodic polling to restart failed
  67. processes.
  68. Extensible
  69. Supervisor has a simple event notification protocol that programs
  70. written in any language can use to monitor it, and an XML-RPC
  71. interface for control. It is also built with extension points that
  72. can be leveraged by Python developers.
  73. Compatible
  74. Supervisor works on just about everything except for Windows. It is
  75. tested and supported on Linux, Mac OS X, Solaris, and FreeBSD. It is
  76. written entirely in Python, so installation does not require a C
  77. compiler.
  78. Proven
  79. While Supervisor is very actively developed today, it is not new
  80. software. Supervisor has been around for years and is already in use
  81. on many servers.
  82. Supervisor Components
  83. ---------------------
  84. :program:`supervisord`
  85. The server piece of supervisor is named :program:`supervisord`. It
  86. is responsible for starting child programs at its own invocation,
  87. responding to commands from clients, restarting crashed or exited
  88. subprocesseses, logging its subprocess ``stdout`` and ``stderr``
  89. output, and generating and handling "events" corresponding to points
  90. in subprocess lifetimes.
  91. The server process uses a configuration file. This is typically
  92. located in :file:`/etc/supervisord.conf`. This configuration file
  93. is an "Windows-INI" style config file. It is important to keep this
  94. file secure via proper filesystem permissions because it may contain
  95. unencrypted usernames and passwords.
  96. :program:`supervisorctl`
  97. The command-line client piece of the supervisor is named
  98. :program:`supervisorctl`. It provides a shell-like interface to the
  99. features provided by :program:`supervisord`. From
  100. :program:`supervisorctl`, a user can connect to different
  101. :program:`supervisord` processes, get status on the subprocesses
  102. controlled by, stop and start subprocesses of, and get lists of
  103. running processes of a :program:`supervisord`.
  104. The command-line client talks to the server across a UNIX domain
  105. socket or an internet (TCP) socket. The server can assert that the
  106. user of a client should present authentication credentials before it
  107. allows him to perform commands. The client process typically uses
  108. the same configuration file as the server but any configuration file
  109. with a ``[supervisorctl]`` section in it will work.
  110. Web Server
  111. A (sparse) web user interface with functionality comparable to
  112. :program:`supervisorctl` may be accessed via a browser if you start
  113. :program:`supervisord` against an internet socket. Visit the server
  114. URL (e.g. ``http://localhost:9001/``) to view and control process
  115. status through the web interface after activating the configuration
  116. file's ``[inet_http_server]`` section.
  117. XML-RPC Interface
  118. The same HTTP server which serves the web UI serves up an XML-RPC
  119. interface that can be used to interrogate and control supervisor and
  120. the programs it runs. See :ref:`xml_rpc`.
  121. Platform Requirements
  122. ---------------------
  123. Supervisor has been tested and is known to run on Linux (Ubuntu 9.10),
  124. Mac OS X (10.4/10.5/10.6), and Solaris (10 for Intel) and FreeBSD 6.1.
  125. It will likely work fine on most UNIX systems.
  126. Supervisor will *not* run at all under any version of Windows.
  127. Supervisor is known to work with Python 2.5 or later but will not work
  128. under any version of Python 3.