Copy config.template.py to config.py and fill out the paths to the drupal base installation (contains /vendor and /web) and the log file. Also fill out the database details for the communication database.
lrvspDaemon.template.service is a template that you can use to create a systemd service file to run the daemon on boot.
If run from inside the LRVSP_Python directory, the following snippet of shell script will automatically configure the service as follows:
- A python venv will be created in
./venv - The daemon will be run as the (at the time of configuring) currently logged in user.
- The dameon will be run using the venv created in (1)
python3 -m venv ./venv
source ./venv/bin/activate
pip install -r requirements.txt
deactivate
export GROUP=$(id -gn)
export LRVSP_PYTHON_VENV="$(realpath ./venv)"
export LRVSP_PYTHON_ROOT="$(realpath .)"
envsubst < lrvspDaemon.template.service | sudo tee /etc/systemd/system/lrvspDaemon.service
sudo systemctl daemon-reloadAfter this, you should be free to start the daemon (with systemctl start lrvspDaemon.service) or enable it for future boots (systemctl enable lrvspDaemon.service).
If the above configuration is not to your liking, consider the following:
- Is the daemon being run using a venv, or using system packages?
- If using a venv, replace
$LRVSP_PYTHON_VENVin the file with the absolute path to your venv (i.e./home/$USER/LRVSP_Python/venv) - If not using a venv, change
LRVSP_PYTHON_VENV/bin/pythonin theExecfield topython, and remove$LRVSP_PYTHON_VENV/bin:from theEnvironment="PATH
- Are you planning on running the daemon as the (at the time of configuring) currently logged in user?
- If yes,
- Replace
$USERin the file with the username of the currently logged in user (or the username of the user you wish to use). - Replace
$GROUPin the file with the group name of the currently logged in user (or the groupname of the user you wish to use). This is usually the same as the username, but can be found by runningid -gn. - Replace
$HOMEwith the home directory of the currently logged in user (or the home directory of the user you wish to use).
- Replace
- If no,
- Remove the
USER,GROUP, andEnvironment="HOMEfields from the file
- Remove the
- Set
$LRVSP_PYTHON_VENVto the root directory of the project - Copy the file to
/etc/systemd/system/lrvspDaemon.service, and reload systemd usingsystemctl daemon-reload.
After this, you should be free to start the daemon (with systemctl start lrvspDaemon.service) or enable it for future boots (systemctl enable lrvspDaemon.service).