Supervisor can be used to protect processes running under Linux, providing start/stop/restart and other functions to ensure that the process is not accidentally killed by other processes.
First apt-get install supervisor
supervisord is the daemon main program, which generates the default configuration file echo_supervisord_conf > /etc/supervisord.conf, Start the service supervisord -c /home/supervisord.conf
Open supervisorctl and find that there are no monitored services.
Now write the process configuration to be managed, similar to the following
[program:gftrader]command=python3 /home/gftrader/runStrategy.py directory=/home/gftrader/ autorestart=true log_stdout=true log_stderr=true exitcodes=0,2stopsignal=QUIT stopwaitsecs=10stdout_logfile=/tmp/gftrader.log
supervisorctl reread, then update, status checks the status, help can look at other commands
The above is the detailed content of A brief introduction to supervisor. For more information, please follow other related articles on the PHP Chinese website!