Top:
pip install supervisor is recommended to install the latest version of supervisor. The highest version of yum install supervisor is 3.1.4. There are many bug s.
Name explanation
supervisor: The name of the software to be installed.
Supervisord: After installing the supervisor software, supervisord is used to start the supervisor service.
supervisorctl: Used to manage program in supervisor configuration file.
Installation with yum
yum install epel-release yum install supervisor systemctl enable supervisord.service # Start-up self-start systemctl start supervisord.service # Start the supervisord service systemctl status supervisord.service # View supervisord service status # Open web service: modify supervisord.conf, inet_http_server node uncomment. vim /etc/supervisord.conf supervisorctl reload [inet_http_server] ; inet (TCP) server disabled by default port=*:9001 ; (ip_address:port specifier, *:port for all iface) username=clark ; (default is no username (open server)) password=123456 ; (default is no password (open server)) ps -ef|grep supervisord # Check to see if supervisord process exists
Application configuration
Supervisor manages the application process and needs to configure each application. Create helloworld.ini in / etc/supervisord.d, one configuration file for each application.
The following is an example of a configuration file:
[program:helloworld] ;Name of program command = dotnet HelloWorld.dll ;Executing commands directory = /root/www/ ;Directory of command execution environment = ASPNETCORE__ENVIRONMENT=Production ;environment variable user = root ;Users of the execution process stopsignal = INT autostart = true ;Whether to start automatically or not autorestart = true ;Whether to restart automatically startsecs = 1 ;Automatic restart interval stderr_logfile = /var/log/helloworld.err.log ;Standard error log stdout_logfile = /var/log/helloworld.out.log ;Standard Output Log
Actual projects:
supervisor Deployment: cd /etc/supervisord.d/ vim product_new_merchant.ini [program:product_new_merchant] user = root directory = /root/data_hub/all_script command = /root/.virtualenvs/ProductNewMerchant/bin/python3.7 product_new_merchant.py autostart = true autorestart = true startsecs = 1 environment = MYSQL_HOST="192.168.6.160",MYSQL_DATABASE="xxxxx",MYSQL_USER_NAME="xxxxxx",MYSQL_PASSWORD="xxxxx",MYSQL_PORT=3306,REDIS_HOST="192.168.95.55",LANG="en_US.utf8",LC_ALL="en_US.UTF-8",LC_LANG="en_US.UTF-8" stdout_logfile = /var/log/product_new_merchant.log redirect_stderr=true stopsignal = INT
After creating the configuration file, restart Supervisor
supervisorctl reload
Or hot restart, no other sub-processes will be restarted
supervisorctl reread supervisorctl update
To ensure that there are no errors and that it can be started properly, use the command mentioned earlier to view the Supervisor status. Or to see if the process to be managed is started, the following commands can be used in this example:
ps -ef | grep HelloWorld.dll //or ps -ef | grep dotnet
Possible problems
1. When I tail on the web page, I either never return or Error response.
Error code 410.
Message: Gone.
2. Inversion of stderr_logfile and stdout_logfile
3, web interface Chinese garbled.
Reference resources: https://www.crifan.com/upgrad...
3.1.4 Old version, upgrade latest version [root@web-95-55 admin]# supervisord --version 3.1.4 //Back up the yum version supervisor configuration file for your reference: yum remove supervisor yum remove python-meld3 pip install supervisor mkdir /etc/supervisor echo_supervisord_conf > /etc/supervisor/supervisord.conf vim /etc/supervisor/supervisord.conf //Modify the application profile path: ;[include] files = /etc/supervisor/config.d/*.ini mkdir /etc/supervisor/config.d cd /etc/supervisor/config.d //Start supervisor: supervisord -c /etc/supervisor/supervisord.conf
Attachment: company operation and maintenance
yum install supervisor -y supervisor Configuration description //The supervisor installed in this form has a directory of configuration files located at: /etc/supervisord.conf (The main configuration file is described in detail below.) /etc/supervisor.d/ (Default child process configuration file, which is where we need to configure according to the program) [unix_http_server] file=/home/supervisor/supervisor.sock ; supervisorctl Used socket Path of file ;chmod=0700 ; Default socket File permission 0700 ;chown=nobody:nogroup ; socket Document owner [inet_http_server] ; provide web Management Background Management Configuration port=0.0.0.0:9001 ; web Managing Background Operations ip Addresses and ports, security considerations for binding external networks ;username=root ; web Manage background login username password ;password=root [supervisord] logfile=/var/log/supervisord.log ; Log file, default in $CWD/supervisord.log logfile_maxbytes=50MB ; Log limit size, more than will generate new files, 0 means no limit logfile_backups=10 ; The default number of log backups is 10,0, which means no backups. loglevel=info ; log level pidfile=/home/supervisor/supervisord.pid ; supervisord pidfile; default supervisord.pid ; pid file nodaemon=false ; Whether to start in the foreground, default background start false minfds=1024 ; Minimum file descriptor can be opened minprocs=200 ; Minimum Openable Processes [supervisorctl] serverurl=unix:/// home/supervisor/supervisor.sock; connect supervisord through socket, path consistent with unix_http_server-> file configuration [include] files = supervisor.d/*.conf ;Specifies in the current directory supervisor.d Configure multiple profiles under folders //Define supervisor management process profile [program:sboot] ;[program:xxx] There xxx Refers to the name of the project. directory = /opt/project ;Directory where the program is located command = java -jar springboot-hello-sample.jar ;Program Start Command autostart=true ;Whether to follow supervisord Start and start autorestart=true; Automatic restart after program exits,Optional values:[unexpected,true,false],Default is unexpected,Represents that the process was inadvertently killed before restarting stopasgroup=true;When a process is killed, does it send to the process group? stop Signals, including subprocesses killasgroup=true;Send to process group kill Signals, including subprocesses stdout_logfile=/var/log/sboot/supervisor.log;The program logs output files, directories need to be created manually stdout_logfile_maxbytes = 50MB;Log size stdout_logfile_backups = 100;Backup number service supervisord restart //Type supervisorctl directly on the command line to display the currently configured project information. [root@wangzh supervisor.d]# supervisorctl sboot RUNNING pid 27517, uptime 0:18:04 supervisor> //Then it can be executed. start/stop/restart sboot To simply control the start and stop of the project, etc. supervisorctl update #Update configuration file supervisorctl reload #Restart the configurable program supervisorctl stop all #Stop all management processes