---
name: "cherryd"
section: "1"
platform: "linux"
package: "python-cherrypy3"
version: "8.9.1-2"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/cherryd"
---

# cherryd(1)

Starts the CherryPy HTTP server as a daemon

## NAME

cherryd - Starts the CherryPy HTTP server as a daemon

## SYNOPSIS

**cherryd** \[-d\] \[-f \| -s\] \[-e ENV\_NAME\] \[-p PIDFILE\_PATH\] \[-P DIRPATH\] \[-c CONFIG\_FILE\] -i MODULE\_NAME

## DESCRIPTION

**cherryd** is a Python script which starts the CherryPy webserver as a daemon.

## OPTIONS

- **-c** *CONFIG\_FILE***, --config=***CONFIG\_FILE*

  Specifies a config file which is to be read and merged into the CherryPy site-wide config dict.  This option may be specified multiple times.  For each CONFIG\_FILE specified, **cherryd** will perform **cherrypy.config.update()**.

- **-d**

  Run the server as a daemon.

- **-e** *ENV\_NAME***, --environment=***ENV\_NAME*

  Specifies the name of an environment to be applied.  An environment is a canned set of configuration entries.  See *ENVIRONMENTS* below for a list of the built-in environments.

- **-f**

  Start a fastcgi server instead of the default HTTP server.

- **-s**

  Start a scgi server instead of the default HTTP server.

- **-i** *MODULE\_NAME***, --import=***MODULE\_NAME*

  Specifies a module to import.  This option may be specified multiple times. For each MODULE\_NAME specified, **cherryd** will import the module.  This is how you tell **cherryd** to run your application´s startup code. For all practical purposes, **-i** is not optional; you will always need to specify at least one module.

- **-p** *PIDFILE\_PATH***, --pidfile=***PIDFILE\_PATH*

  Store the process id in PIDFILE\_PATH.

- **-P** *DIRPATH***, --Path** *DIRPATH*

  Specifies a directory to be inserted at the head of **sys.path**.  DIRPATH should be an absolute path.  This option may be specified multiple times. **cherryd** inserts all the specified DIRPATHs into **sys.path** before it attempts to import modules specified with **-i**.

For a terse summary of the options, run **cherryd --help**.

## EXAMPLES

A site-wide configuration file **site.conf**:

\[global\]\
 server.socket\_host = "0.0.0.0"\
 server.socket\_port = 8008\
 engine.autoreload.on = False\

The application startup code in **startup.py**:

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)\

A corresponding **cherryd** command line:

cherryd -d -c site.conf -i startup -p /var/log/cherrypy/my\_app.pid\

## DROPPING PRIVILEGES

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 the values for **uid** and **gid** may be either user and group names, or uid and gid integers.

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.

## ENVIRONMENTS

These are the built-in environment configurations:

### staging

´engine.autoreload.on´: False,\
 ´checker.on´: False,\
 ´tools.log\_headers.on´: False,\
 ´request.show\_tracebacks´: False,\
 ´request.show\_mismatched\_params´: False,\

### production

´engine.autoreload\_on´: False,\
 ´checker.on´: False,\
 ´tools.log\_headers.on´: False,\
 ´request.show\_tracebacks´: False,\
 ´request.show\_mismatched\_params´: False,\
 ´log.screen´: False,\

### embedded

\# 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,\

## BUGS

**cherryd** should probably accept command-line options **--uid**, **--gid**, and **--umask**, and handle dropping privileges itself.

## AUTHOR

fumanchu

```
cherrypy.org
```

## COPYRIGHT

This man page is placed in the public domain
