cherryd(1) | web | cherryd(1) |
cherryd - Starts the CherryPy HTTP server as a daemon
cherryd [-d] [-f | -s] [-e ENV_NAME] [-p PIDFILE_PATH] [-P DIRPATH] [-c CONFIG_FILE] -i MODULE_NAME
cherryd is a Python script which starts the CherryPy webserver as a daemon.
For a terse summary of the options, run cherryd --help.
A site-wide configuration file site.conf:
[global]
server.socket_host = "0.0.0.0"
server.socket_port = 8008
engine.autoreload.on = False
import cherrypy
import my_controller
cherrypy.log.error_file = ´/var/tmp/myapp-error.log´
cherrypy.log.access_file = ´/var/tmp/myapp-access.log´
config_root = { ´tools.encode.encoding´ : ´utf-8´,
}
app_conf = { ´/´ : config_root }
cherrypy.tree.mount(my_controller.Root(), script_name=´´,
config=app_conf)
cherryd -d -c site.conf -i startup -p /var/log/cherrypy/my_app.pid
If you want to serve your web application on TCP port 80 (or any port lower than 1024), the CherryPy HTTP server needs to start as root in order to bind to the port. Running a web application as root is reckless, so the application should drop privileges from root to some other user and group. The application must do this itself, as cherryd does not do it for you.
To drop privileges, put the following lines into your startup code, substituting appropriate values for umask, uid and gid:
from cherrypy.process.plugins import DropPrivileges
DropPrivileges(cherrypy.engine, umask=022, uid=´nobody´,
gid=´nogroup´).subscribe()
Note that you must disable the engine Autoreload plugin, because the way Autoreload works is by exec()ing a new instance of the running process, replacing the current instance. Since root privileges are already dropped, the new process instance will fail when it tries to perform a privileged operation such as binding to a low-numbered TCP port.
These are the built-in environment configurations:
´engine.autoreload.on´: False,
´checker.on´: False,
´tools.log_headers.on´: False,
´request.show_tracebacks´: False,
´request.show_mismatched_params´: False,
´engine.autoreload_on´: False,
´checker.on´: False,
´tools.log_headers.on´: False,
´request.show_tracebacks´: False,
´request.show_mismatched_params´: False,
´log.screen´: False,
# For use with CherryPy embedded in another deployment stack, e.g.
Apache mod_wsgi.
´engine.autoreload_on´: False,
´checker.on´: False,
´tools.log_headers.on´: False,
´request.show_tracebacks´: False,
´request.show_mismatched_params´: False,
´log.screen´: False,
´engine.SIGHUP´: None,
´engine.SIGTERM´: None,
cherryd should probably accept command-line options --uid, --gid, and --umask, and handle dropping privileges itself.
fumanchu
cherrypy.org
This man page is placed in the public domain
2009-06-15 | 3.2.0 |