Answer the question
In order to leave comments, you need to log in
How to run a python script in the background for permanent work on a VPS?
Hello!
Python script listens to a queue. Accordingly, when something appears in the queue, it must process the message.
It is also necessary to ensure the control of the script in the sense that if the script stops working for any reason, it must be restarted.
Please advise how this can be done?
Answer the question
In order to leave comments, you need to log in
Use supervisor . It automatically restarts the process according to the criteria.
Minimum conf:
[program:worker]
command=python /root/test.py
stdout_logfile=/var/log/worker.log
autostart=true
autorestart=true
user=root
stopsignal=KILL
numprocs=1
If relative paths are used in the system, then be sure to use the directory option.
By default, the script is run from /
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question