Running python script with upstart

109 Views Asked by At

I try to run python script, script runs multiple processes and one process runs multiple threads. This script run under root and 'initctl stop script' done successfully (script stops), but if I run this script under another user script dont stop (initctl logged that job stops, but in htop many script instances worked). This script worked properly:

description "Script daemon"

start on runlevel [2345]
stop on runlevel [016]

respawn

chdir /tmp
script
   . /opt/venv/bin/activate
   python script.py
end script

This script dont stop:

description "Script daemon"

start on runlevel [2345]
stop on runlevel [016]

respawn

chdir /tmp
script
   . /opt/venv/bin/activate
   exec su -s /bin/sh -c 'exec "$0" "$@"' another_user --python script.py
end script

How can I change second script for normal stop?

0

There are 0 best solutions below