I have written a module in Python and want it to run continuously once started and need to stop it when I need to update other modules. I will likely be using monit to resta
You could check out supervisor. What it is capable of is starting a process at system startup, and then keeping it alive until shutdown.
The simplest configuration file would be:
[program:my_script]
command = /home/foo/bar/venv/bin/python /home/foo/bar/scripts/my_script.py
environment = MY_ENV_VAR=FOO, MY_OTHER_ENV_VAR=BAR
autostart = True
autorestart = True
Then you could link it to /etc/supervisord/conf.d
, run sudo supervisorctl
to enter management console of supervisor, type in reread
so that supervisor notices new config entry and update
to display new programs on the status
list.
To start/restart/stop a program you could execute sudo supervisorctl start/restart/stop my_script
.