A
A
albertalexandrov2018-05-01 10:58:03
Python
albertalexandrov, 2018-05-01 10:58:03

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

3 answer(s)
F
Fixid, 2018-05-01
@albertalexandrov

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 /

S
sim3x, 2018-05-01
@sim3x

systemd

P
Puma Thailand, 2018-05-01
@opium

Screen

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question