summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLawouach <sh@defuze.org>2014-05-12 21:38:24 +0200
committerLawouach <sh@defuze.org>2014-05-12 21:38:24 +0200
commit7f82096386d565c9a9a1bf7405c860a786458ec7 (patch)
tree2ad5ff76f4859e1ec434a09c6d81dc2185d095ec
parenta983b4b918cec8952d0736f5003bc521264f16a8 (diff)
downloadcherrypy-7f82096386d565c9a9a1bf7405c860a786458ec7.tar.gz
supervisord config
-rw-r--r--sphinx/source/deploy.rst73
1 files changed, 73 insertions, 0 deletions
diff --git a/sphinx/source/deploy.rst b/sphinx/source/deploy.rst
index da0bc0e3..3437487d 100644
--- a/sphinx/source/deploy.rst
+++ b/sphinx/source/deploy.rst
@@ -85,6 +85,79 @@ provide a 'pidfile' argument, preferably an absolute path:
PIDFile(cherrypy.engine, '/var/run/myapp.pid').subscribe()
+Control via Supervisord
+#######################
+
+`Supervisord <http://supervisord.org>`_ is a powerful process control
+and management tool that can perform a lot of tasks around process monitoring.
+
+Below is a simple supervisor configuration for your CherryPy
+application.
+
+.. code-block:: ini
+
+ [unix_http_server]
+ file=/tmp/supervisor.sock
+
+ [supervisord]
+ logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
+ logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
+ logfile_backups=10 ; (num of main logfile rotation backups;default 10)
+ loglevel=info ; (log level;default info; others: debug,warn,trace)
+ pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
+ nodaemon=false ; (start in foreground if true;default false)
+ minfds=1024 ; (min. avail startup file descriptors;default 1024)
+ minprocs=200 ; (min. avail process descriptors;default 200)
+
+ [rpcinterface:supervisor]
+ supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
+
+ [supervisorctl]
+ serverurl=unix:///tmp/supervisor.sock
+
+ [program:myapp]
+ command=python server.py
+ environment=PYTHONPATH=.
+ directory=.
+
+This could control your server via the ``server.py`` module as
+the application entry point.
+
+.. code-block:: python
+
+ import cherrypy
+
+ class Root(object):
+ @cherrypy.expose
+ def index(self):
+ return "Hello World!"
+
+
+ cherrypy.config.update({'server.socket_port': 8090,
+ 'engine.autoreload_on': False,
+ 'log.access_file': './access.log',
+ 'log.error_file': './error.log'})
+ cherrypy.quickstart(Root())
+
+To take the configuration (assuming it was saved in a file
+called ``supervisor.conf``) into account:
+
+.. code-block:: bash
+
+ $ supervisord -c supervisord.conf
+ $ supervisorctl update
+
+Now, you can point your browser at http://localhost:8090/
+and it will display `Hello World!`.
+
+To stop supervisor, type:
+
+.. code-block:: bash
+
+ $ supervisorctl shutdown
+
+This will obviously shutdown your application.
+
.. _ssl:
SSL support