Okay, so after some extensive testing I figured it out.
Runit will send the kill signal to the run
script, which does not propogate it by default. What you need to make sure is that you call exec python yourscript.py
in the end. Similarly, if your run
script calls another shell script (ie. one that activates your virtualenv or similar), it must do so with exec
as well.
Samples:
run
:
#!/bin/sh
umask 002
2>&1
exec chpst -uanalytics cliscript router
cliscript
:
#!/bin/sh
# Resolve script path, assuming that the script resides in $(ABSPATH)/bin
SCRIPTPATH="$0"
if [ -h "$SCRIPTPATH" ]; then
SCRIPTPATH=$(readlink -e "$0")
fi
ABSPATH=$(dirname "$(cd "$(dirname "$SCRIPTPATH")"; pwd -L)")
# Load the virtual environment
source "$ABSPATH/venv/bin/activate"
# Set up environment
export PYTHONUNBUFFERED=1
exec python "$ABSPATH/bin/processing-cli.py" $@
Take note of the exec
being called when we "pass" control to the next script or python itself.