Installation and operation of Supervisor

Time:2020-1-17

supervisor

1、 Install supervisor installation

Note: all of the following operations are performed in centos7

1. Install centos7 extended software warehouse

sudo yum install -y epel-release

2. Install Supervisor

yum install -y supervisor

3. View the installation path

rpm -ql supervisor

4. Modify and define INI file

step1:

Find the file of the supervisor’s configuration. For example:whereis supervisord.ini perhapsfind / -name supervisor* Command to query

step2:

Modify the configuration file, and modify the INI file path in the last line of the configuration file, which means that the supervisor will load the
All suffixes areiniDocuments.

Installation and operation of Supervisor
Installation and operation of Supervisor

step3:

EstablishiniFile, join in the process management of supervisor, and realize the background operation of server
[program:exmaple] 
		#Example is the name of the process in the supervisor, whatever you choose
		command=/usr/local/bin/gunicorn -w 4 -b 127.0.0.1:91 run:app 
		#The above code is to run flash with gunicorn. Run is your filename: app means app = flask (\\\\\\\\\
		Or
		command=/usr/local/bin/python3 /root/test/test.py
		#Command = file to be run in the path where the instruction is running (PS: absolute path is recommended)

		directory=/root/test/
		#Absolute path of the file to run
		autostart=true
		autorestart=true
		priority=5
		killasgroup=true
stopasgroup=true
Python running single file configuration example

In fact, if you only run a single file, you can directly usenohup python test.py &(PS: needcdreachtestExecute this command in the folder) to run the server in the background, and at the same timetest.pyGenerated under the foldernohup.outlog file

[program:myProgram]
		command=python /home/myname/test.py
		autostart=true
		autorestart=ture
stdout_logfile=/home/myname/test.log
An example of the configuration file of running flash by gunicore
[program:myProgram]
		command=/usr/local/bin/gunicorn -w 4 -b 127.0.0.1:91 flask:app
		directory=/root/example/
		autostart=true
		autorestart=true
		priority=5
		killasgroup=true
stopasgroup=true

2、 Start Supervisor

supervisord
		#Start supervisor and specify the conf file path
		Absolute path of Supervisor - C configuration file
		e.g: supervisord -c /etc/supervisor/supervisord.conf  

		#Close Supervisor
supervisorctl shutdown

1. Start the supervisor service

supervisorctl start all    
		#Turn on all
		supervisorctl status 
#View supervisor service status

2. After modifying the supervisor INI file or conf file configuration, the service needs to be updated

supervisorctl update 
		#Update the configuration of Supervisor
		supervisorctl reload 
#Reload project into memory

3. Restart the supervisor service

supervisorctl restart
#Whether it is currently closed or running

4. Log path

tail -f /var/log/supervisor/supervisord.log

5. Close the service of Supervisor

supervisorctl stop all 
		#Close all
		supervisorctl stop example 
		#Turn off one of them

3、 About reporting errors

Basically, I have reported all the errors, but they are classified into three categories:

  1. Supervisor is not started —– > Run Supervisor command
  2. There is an error in your profile content ——– check your profile content
  3. There is an error in the code you need to run —– > check your code:

4、 Reading feedback

If you have any help, you can like it. If you think it’s not detailed enough, you can comment and point out.

Thank you for reading.