If you configure a site type that supports arbitrary daemon processes, the infrastructure that initializes them does not process command line arguments. In the rare case that you don't need any, you can run the daemon executable directly from the 'Command' field of the Daemon management interface. In all other cases, you will need a run script.
A run script is a short shell script that lets you customize the environment for your daemon without worrying about the massive stack of stuff we have to do to make sure your daemon runs in the context of your site. A typical, minimal run script is an executable file that looks like this:
exec /home/protected/bin/mydaemon.py --port=12345 --run-in-foreground
Then, you enter the path to the run script as the command in your daemon configuration. This lets you customize the daemon's command line arguments. You can also take other actions if needed, like setting environment variables, removing temporary files from previous runs, running preflight database checks, etc.
When writing run scripts, always make sure the following key elements are present:
- The shebang line is the first line of the run script. (#!/bin/sh)
- The exec command in front of the daemon executable. (Saves RAM = lower costs, may also avoid problems with signal delivery.)
- The daemon must run in the foreground. (Otherwise it will be repeatedly killed and restarted.)
- Starting the daemon is the last line in the run script. (Anything after that will almost never be run.)
- Executable permissions on the run script. (chmod a+x myrun.sh)