| 1 |
.\" Man page generated from reStructuredText. |
|---|
| 2 |
.TH cherryd 1 "2009-06-15" "3.2.0" "web" |
|---|
| 3 |
.SH NAME |
|---|
| 4 |
cherryd \- Starts the CherryPy HTTP server as a daemon |
|---|
| 5 |
|
|---|
| 6 |
.nr rst2man-indent-level 0 |
|---|
| 7 |
. |
|---|
| 8 |
.de1 rstReportMargin |
|---|
| 9 |
\\$1 \\n[an-margin] |
|---|
| 10 |
level \\n[rst2man-indent-level] |
|---|
| 11 |
level magin: \\n[rst2man-indent\\n[rst2man-indent-level]] |
|---|
| 12 |
- |
|---|
| 13 |
\\n[rst2man-indent0] |
|---|
| 14 |
\\n[rst2man-indent1] |
|---|
| 15 |
\\n[rst2man-indent2] |
|---|
| 16 |
.. |
|---|
| 17 |
.de1 INDENT |
|---|
| 18 |
.\" .rstReportMargin pre: |
|---|
| 19 |
. RS \\$1 |
|---|
| 20 |
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] |
|---|
| 21 |
. nr rst2man-indent-level +1 |
|---|
| 22 |
.\" .rstReportMargin post: |
|---|
| 23 |
.. |
|---|
| 24 |
.de UNINDENT |
|---|
| 25 |
. RE |
|---|
| 26 |
.\" indent \\n[an-margin] |
|---|
| 27 |
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] |
|---|
| 28 |
.nr rst2man-indent-level -1 |
|---|
| 29 |
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] |
|---|
| 30 |
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u |
|---|
| 31 |
.. |
|---|
| 32 |
|
|---|
| 33 |
.SH SYNOPSIS |
|---|
| 34 |
\fBcherryd\fP [\-d] [\-f | \-s] [\-e ENV_NAME] [\-p PIDFILE_PATH] [\-P DIRPATH] [\-c CONFIG_FILE] \-i MODULE_NAME |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
.SH DESCRIPTION |
|---|
| 38 |
\fBcherryd\fP is a Python script which starts the CherryPy webserver as a daemon. |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
.SH OPTIONS |
|---|
| 42 |
.INDENT 0.0 |
|---|
| 43 |
|
|---|
| 44 |
.TP |
|---|
| 45 |
.BI \-c\ CONFIG_FILE ,\ \-\-config\fn= CONFIG_FILE |
|---|
| 46 |
Specifies a config file which is to be read and merged into the |
|---|
| 47 |
CherryPy site\-wide config dict. This option may be specified |
|---|
| 48 |
multiple times. For each CONFIG_FILE specified, \fBcherryd\fP will perform |
|---|
| 49 |
\fBcherrypy.config.update()\fP. |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
.TP |
|---|
| 53 |
.B \-d |
|---|
| 54 |
Run the server as a daemon. |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
.TP |
|---|
| 58 |
.BI \-e\ ENV_NAME ,\ \-\-environment\fn= ENV_NAME |
|---|
| 59 |
Specifies the name of an environment to be applied. An environment is a |
|---|
| 60 |
canned set of configuration entries. See \fI\%ENVIRONMENTS\fP below for a |
|---|
| 61 |
list of the built\-in environments. |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
.TP |
|---|
| 65 |
.B \-f |
|---|
| 66 |
Start a fastcgi server instead of the default HTTP server. |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
.TP |
|---|
| 70 |
.B \-s |
|---|
| 71 |
Start a scgi server instead of the default HTTP server. |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
.TP |
|---|
| 75 |
.BI \-i\ MODULE_NAME ,\ \-\-import\fn= MODULE_NAME |
|---|
| 76 |
Specifies a module to import. This option may be specified multiple times. |
|---|
| 77 |
For each MODULE_NAME specified, \fBcherryd\fP will import the module. This |
|---|
| 78 |
is how you tell \fBcherryd\fP to run your application\'s startup code. |
|---|
| 79 |
For all practical purposes, \fB\-i\fP is not optional; you will always need to |
|---|
| 80 |
specify at least one module. |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
.TP |
|---|
| 84 |
.BI \-p\ PIDFILE_PATH ,\ \-\-pidfile\fn= PIDFILE_PATH |
|---|
| 85 |
Store the process id in PIDFILE_PATH. |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
.TP |
|---|
| 89 |
.BI \-P\ DIRPATH ,\ \-\-Path\ DIRPATH |
|---|
| 90 |
Specifies a directory to be inserted at the head of \fBsys.path\fP. DIRPATH |
|---|
| 91 |
should be an absolute path. This option may be specified multiple times. |
|---|
| 92 |
\fBcherryd\fP inserts all the specified DIRPATHs into \fBsys.path\fP before it |
|---|
| 93 |
attempts to import modules specified with \fB\-i\fP. |
|---|
| 94 |
|
|---|
| 95 |
.UNINDENT |
|---|
| 96 |
For a terse summary of the options, run \fBcherryd \-\-help\fP. |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
.SH EXAMPLES |
|---|
| 100 |
A site\-wide configuration file \fBsite.conf\fP: |
|---|
| 101 |
|
|---|
| 102 |
.INDENT 0.0 |
|---|
| 103 |
.INDENT 3.5 |
|---|
| 104 |
|
|---|
| 105 |
[global] |
|---|
| 106 |
.br |
|---|
| 107 |
server.socket_host = "0.0.0.0" |
|---|
| 108 |
.br |
|---|
| 109 |
server.socket_port = 8008 |
|---|
| 110 |
.br |
|---|
| 111 |
engine.autoreload_on = False |
|---|
| 112 |
.br |
|---|
| 113 |
|
|---|
| 114 |
.UNINDENT |
|---|
| 115 |
.UNINDENT |
|---|
| 116 |
The application startup code in \fBstartup.py\fP: |
|---|
| 117 |
|
|---|
| 118 |
.INDENT 0.0 |
|---|
| 119 |
.INDENT 3.5 |
|---|
| 120 |
|
|---|
| 121 |
import cherrypy |
|---|
| 122 |
.br |
|---|
| 123 |
import my_controller |
|---|
| 124 |
.br |
|---|
| 125 |
cherrypy.log.error_file = \'/var/tmp/myapp\-error.log\' |
|---|
| 126 |
.br |
|---|
| 127 |
cherrypy.log.access_file = \'/var/tmp/myapp\-access.log\' |
|---|
| 128 |
.br |
|---|
| 129 |
config_root = { \'tools.encode.encoding\' : \'utf\-8\', } |
|---|
| 130 |
.br |
|---|
| 131 |
app_conf = { \'/\' : config_root } |
|---|
| 132 |
.br |
|---|
| 133 |
cherrypy.tree.mount(my_controller.Root(), script_name=\'\', config=app_conf) |
|---|
| 134 |
.br |
|---|
| 135 |
|
|---|
| 136 |
.UNINDENT |
|---|
| 137 |
.UNINDENT |
|---|
| 138 |
A corresponding \fBcherryd\fP command line: |
|---|
| 139 |
|
|---|
| 140 |
.INDENT 0.0 |
|---|
| 141 |
.INDENT 3.5 |
|---|
| 142 |
|
|---|
| 143 |
cherryd \-d \-c site.conf \-i startup \-p /var/log/cherrypy/my_app.pid |
|---|
| 144 |
.br |
|---|
| 145 |
|
|---|
| 146 |
.UNINDENT |
|---|
| 147 |
.UNINDENT |
|---|
| 148 |
|
|---|
| 149 |
.SH DROPPING PRIVILEGES |
|---|
| 150 |
If you want to serve your web application on TCP port 80 (or any port lower than |
|---|
| 151 |
1024), the CherryPy HTTP server needs to start as root in order to bind to the |
|---|
| 152 |
port. Running a web application as root is reckless, so the application should |
|---|
| 153 |
drop privileges from root to some other user and group. The application must do |
|---|
| 154 |
this itself, as \fBcherryd\fP does not do it for you. |
|---|
| 155 |
|
|---|
| 156 |
To drop privileges, put the following lines into your startup code, |
|---|
| 157 |
substituting appropriate values for \fBumask\fP, \fBuid\fP and \fBgid\fP: |
|---|
| 158 |
|
|---|
| 159 |
.INDENT 0.0 |
|---|
| 160 |
.INDENT 3.5 |
|---|
| 161 |
|
|---|
| 162 |
from cherrypy.process.plugins import DropPrivileges |
|---|
| 163 |
.br |
|---|
| 164 |
DropPrivileges(cherrypy.engine, umask=022, uid=\'nobody\', gid=\'nogroup\').subscribe() |
|---|
| 165 |
.br |
|---|
| 166 |
|
|---|
| 167 |
.UNINDENT |
|---|
| 168 |
.UNINDENT |
|---|
| 169 |
Note that the values for \fBuid\fP and \fBgid\fP may be either user and group |
|---|
| 170 |
names, or uid and gid integers. |
|---|
| 171 |
|
|---|
| 172 |
Note that you must disable the engine Autoreload plugin, because the way |
|---|
| 173 |
Autoreload works is by \fBexec()\fPing a new instance of the running process, |
|---|
| 174 |
replacing the current instance. Since root privileges are already dropped, the |
|---|
| 175 |
new process instance will fail when it tries to perform a privileged operation |
|---|
| 176 |
such as binding to a low\-numbered TCP port. |
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
.SH ENVIRONMENTS |
|---|
| 180 |
These are the built\-in environment configurations: |
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
.SS staging |
|---|
| 184 |
.INDENT 0.0 |
|---|
| 185 |
.INDENT 3.5 |
|---|
| 186 |
|
|---|
| 187 |
\'engine.autoreload_on\': False, |
|---|
| 188 |
.br |
|---|
| 189 |
\'checker.on\': False, |
|---|
| 190 |
.br |
|---|
| 191 |
\'tools.log_headers.on\': False, |
|---|
| 192 |
.br |
|---|
| 193 |
\'request.show_tracebacks\': False, |
|---|
| 194 |
.br |
|---|
| 195 |
\'request.show_mismatched_params\': False, |
|---|
| 196 |
.br |
|---|
| 197 |
|
|---|
| 198 |
.UNINDENT |
|---|
| 199 |
.UNINDENT |
|---|
| 200 |
|
|---|
| 201 |
.SS production |
|---|
| 202 |
.INDENT 0.0 |
|---|
| 203 |
.INDENT 3.5 |
|---|
| 204 |
|
|---|
| 205 |
\'engine.autoreload_on\': False, |
|---|
| 206 |
.br |
|---|
| 207 |
\'checker.on\': False, |
|---|
| 208 |
.br |
|---|
| 209 |
\'tools.log_headers.on\': False, |
|---|
| 210 |
.br |
|---|
| 211 |
\'request.show_tracebacks\': False, |
|---|
| 212 |
.br |
|---|
| 213 |
\'request.show_mismatched_params\': False, |
|---|
| 214 |
.br |
|---|
| 215 |
\'log.screen\': False, |
|---|
| 216 |
.br |
|---|
| 217 |
|
|---|
| 218 |
.UNINDENT |
|---|
| 219 |
.UNINDENT |
|---|
| 220 |
|
|---|
| 221 |
.SS embedded |
|---|
| 222 |
.INDENT 0.0 |
|---|
| 223 |
.INDENT 3.5 |
|---|
| 224 |
|
|---|
| 225 |
# For use with CherryPy embedded in another deployment stack, e.g. Apache mod_wsgi. |
|---|
| 226 |
.br |
|---|
| 227 |
\'engine.autoreload_on\': False, |
|---|
| 228 |
.br |
|---|
| 229 |
\'checker.on\': False, |
|---|
| 230 |
.br |
|---|
| 231 |
\'tools.log_headers.on\': False, |
|---|
| 232 |
.br |
|---|
| 233 |
\'request.show_tracebacks\': False, |
|---|
| 234 |
.br |
|---|
| 235 |
\'request.show_mismatched_params\': False, |
|---|
| 236 |
.br |
|---|
| 237 |
\'log.screen\': False, |
|---|
| 238 |
.br |
|---|
| 239 |
\'engine.SIGHUP\': None, |
|---|
| 240 |
.br |
|---|
| 241 |
\'engine.SIGTERM\': None, |
|---|
| 242 |
.br |
|---|
| 243 |
|
|---|
| 244 |
.UNINDENT |
|---|
| 245 |
.UNINDENT |
|---|
| 246 |
|
|---|
| 247 |
.SH BUGS |
|---|
| 248 |
\fBcherryd\fP should probably accept command\-line options \fB\-\-uid\fP, \fB\-\-gid\fP, and |
|---|
| 249 |
\fB\-\-umask\fP, and handle dropping privileges itself. |
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 |
.SH AUTHOR |
|---|
| 253 |
fumanchu |
|---|
| 254 |
|
|---|
| 255 |
.nf |
|---|
| 256 |
cherrypy.org |
|---|
| 257 |
.fi |
|---|
| 258 |
|
|---|
| 259 |
.SH COPYRIGHT |
|---|
| 260 |
This man page is placed in the public domain |
|---|
| 261 |
|
|---|
| 262 |
.\" Generated by docutils manpage writer on 2009-06-15 15:07. |
|---|
| 263 |
.\" |
|---|