How to run python script in background on a permanent job on a VPS?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
21 views
Hello!

A Python script listens to the queue. Accordingly, when something appears in the queue, it must process the message.

It is also necessary to ensure control of the script in the sense that if the script has stopped working for any reason, it is necessary to re-run.

Please suggest how it can be implemented?
by | 21 views

3 Answers

0 like 0 dislike
Use supervisor. It automatically restarts the process according to the criteria.

A minimal 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 you use relative paths in the system, be sure to use the directory parameter.
By default the script is run from /
by
0 like 0 dislike
systemd
by
0 like 0 dislike
Screen
by

Related questions

0 like 0 dislike
3 answers
0 like 0 dislike
4 answers
asked Mar 25, 2019 by Pshon
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
36,488 users