Software and hardware environment
cat /etc/redhat-release # View the system version
Supervisor IntroductionSupervisor is a process management tool written in Python. It can easily monitor, start, stop, and restart one or more processes. When a process is killed unexpectedly, the supervisor can monitor the process death and easily restore the process automatically, without the need for programmers or system administrators to write code to control it. Supervisord installationyum install -y epel-release yum install -y supervisor Start & Enable Auto-Start systemctl start supervisord systemctl enable supervisord Other commands: systemctl stop supervisord #Stop and startsystemctl start supervisord #Startsystemctl status supervisord #Start statussystemctl reload supervisord #Heavy loadsystemctl restart supervisord #Restart Supervisor's web clientSupervisor provides web-based control. Administrators can start and restart processes by clicking buttons on the page, which is very convenient. Enter the configuration file and enable support for the web client vim /etc/supervisord.conf If it is provided for external access, the port needs to be changed to the local IP address #Uncomment lines 10-13. The numbers in front are line numbers [inet_http_server] ; inet (TCP) server disabled by default port=192.168.26.121:9001 ; (ip_address:port specifier, *:port for all iface) username=user ; (default is no username (open server)) password=123 ; (default is no password (open server)) After the configuration is complete, restart the service systemctl restart supervisord supervisord application configurationEnter the supervisord configuration file cat /etc/supervisord.conf The last line of the configuration file shows [include] files = supervisord.d/*.ini That is to say, all our application configuration files are saved in this directory and saved in .ini format. You can modify the address by yourself, but do not modify the suffix So let's create a monitored application Create a test python configurationCreate an application configuration called python vim /etc/supervisord.d/python.ini Configuration file content, where command is the command that needs to be executed when our application starts [program:python] #The python here is the monitoring name we display on the web front end and the terminal command=python /tmp/supervisordtest/test.py #The file address we want to monitor autostart=true autorestart=true startsecs=1 startretries=3 redirect_stderr=true stdout_logfile=/tmp/supervisordtest/access_python.log #Log address, you can configure the directory yourself stderr_logfile=/tmp/supervisordtest/error_python.log #Log address, you can configure the directory yourself Create test.py mkdir /tmp/supervisordtest vim /tmp/supervisordtest/test.py Program content: Start an infinite loop and keep printing content while True: print(100) Restart supervisord to make the configuration file take effect systemctl restart supervisord Check whether the application starts normally 1. Command view systemctl status supervisord 2. Visual web viewing The web terminal can restart, stop, clean up logs, view logs and other operations Several commands related to supervisor After the installation is complete, three system commands 1. 2. supervisorctl is a command line management tool that can be used to execute sudo supervisorctl start demoweb demoweb is the name of the process. For detailed commands and instructions, see the table below.
3. echo_supervisord_conf Used to generate the default configuration file (the default configuration file is very complete and has comments, suitable for reference when needed, the usage is as follows echo_supervisord_conf > test.conf This is the end of the article about how to learn to use supervisor watchdog in 3 minutes. For more information about how to use supervisor in 3 minutes, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Discussion on the way to open website hyperlinks
>>: A preliminary understanding of CSS custom properties
Table of contents 1. Keywords 2. Deconstruction 3...
Copy code The code is as follows: <!DOCTYPE ht...
Inject axios into Vue import axios from 'axio...
Horizontal Line Use the <hr /> tag to draw ...
In the process of writing HTML, we often define mu...
Effect picture (if you want a triangle, please cl...
Before reading this article, I hope you have a ba...
0. Preliminary preparation Disable secure boot in...
Table of contents 1. Prototype chain inheritance ...
Table of contents Creating Arrays in JavaScript U...
When you write buttons (input, button), you will f...
Viewing and Setting SQL Mode in MySQL MySQL can r...
This article mainly introduces the wonderful use ...
Preface In the previous article, we mainly learne...
How to add css in html? There are three ways to s...