11.11. CamCOPS Windows service

The most convenient way of running a CamCOPS server under Windows is via a service.

The service starts the following:

  • the CamCOPS web server, via CherryPy (equivalent to running camcops_server serve_cherrypy);
  • the CamCOPS scheduler, via Celery (equivalent to running camcops_server launch_scheduler);
  • the CamCOPS back-end worker processes, via Celery (equivalent to running camcops_server launch_workers).

To create a Windows service for CamCOPS, use the camcops_windows_service command. You will need to run it from a command prompt with Administrator authority.

Before starting the server, ensure you have set the following two system environment variables:

  • CAMCOPS_WINSERVICE_LOGDIR, determining where disk logs are stored;
  • CAMCOPS_CONFIG_FILE, governing which config file will be used.

Logs from CamCOPS go to files in the directory specified by the environment variable. However, output from the service itself goes to the Windows operating system logs: see Event Viewer ‣ Windows Logs ‣ Application.

11.11.1. camcops_windows_service

Options as of 2019-04-23:

usage: 'camcops_windows_service-script.py [options] install|update|remove|start [...]|stop|restart [...]|debug [...]'
Options for 'install' and 'update' commands only:
 --username domain\username : The Username the service is to run under
 --password password : The password for the username
 --startup [manual|auto|disabled|delayed] : How the service starts, default = manual
 --interactive : Allow the service to interact with the desktop.
 --perfmonini file: .ini file to use for registering performance monitor data
 --perfmondll file: .dll file to use when querying the service for
   performance data, default = perfmondata.dll
Options for 'start' and 'stop' commands only:
 --wait seconds: Wait for the service to actually start or stop.
                 If you specify --wait with the 'stop' option, the service
                 and all dependent services will be stopped, each waiting
                 the specified period.

# The ‘debug’ option runs a service in debugging mode so you can see what it’s doing.