Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

(Centos7) Supervisor installation and deployment

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1.yum installation

Yum install-y epel-releaseyum install-y supervisorsystemctl enable supervisord # Boot systemctl start supervisord # start supervisord service systemctl status supervisord # View supervisord service status ps-ef | grep supervisord # check whether there is a supervisord process

two。 Configuration file

After supervisor is installed successfully, no default configuration file is provided. You can generate the initialization configuration file of supervisor by running the echo_supervisord_conf program.

Mkdir / etc/supervisorecho_supervisord_conf > / etc/supervisor/supervisord.conf

3. Profile parameter description

There are many configuration parameters for supervisor. The following describes the configuration of commonly used parameters, detailed configuration and instructions. Please refer to the official documentation.

Note: the configuration at the beginning of the semicolon (;) indicates comments

[unix_http_server] file=/tmp/supervisor.sock; UNIX socket file, which can be used by supervisorctl; mode of chmod=0700; socket file, default is 0700position Chownkeeper nobodygroup; owner of socket file, format: uid: GID [inet _ http_server]; HTTP server, which provides web management interface port=0.0.0.0:9001 Web manages the IP and port running at the backend. If it is open to the public network, you need to pay attention to security; username=user; user name of login management backend; password=123; password of login management backend [supervisord] logfile=/tmp/supervisord.log; log file. Default is $CWD/supervisord.loglogfile_maxbytes=50MB. Log file size: rotate. Default is 50MB. If set to 0, there is no limit on the size of logfile _ backups=10. The number of reserved backups of log files defaults to 10, and 0 means no backup of loglevel=info. Log level, default info, other: debug,warn,tracepidfile=/tmp/supervisord.pid; pid file nodaemon=false Whether to start in the foreground, the default is false, that is, start minfds=10240 by daemon; the minimum value of file descriptors that can be opened, default 1024minprocs=200; the minimum value of the number of processes that can be opened, default 200 [supervisorctl]; serverurl=unix:///tmp/supervisor.sock; connect supervisord through UNIX socket, and the path is the same as the file of the unix_http_server part serverurl= http://0.0.0.0:9001 Connecting supervisord; [program:xx] through HTTP is the configuration parameter of the managed process. Xx is the name of the process [program:xx] command=/opt/apache-tomcat-8.0.35/bin/catalina.sh run; the program startup command autostart=true; it also starts startsecs=10 automatically when supervisord starts. If there is no abnormal exit after starting 10 seconds, it means that the process has started normally. The default is 1 second autorestart=true. Restart automatically after the program exits. Available values: [unexpected,true,false], default is unexpected, which means startretries=3 is restarted after the process is killed unexpectedly; number of automatic retries after startup failure, default is 3user=tomcat; which user is used to start the process, default is rootpriority=999; process startup priority, default is 999, redirect_stderr=true with low value is preferred; redirect stderr to stdout, default is falsestdout_logfile_maxbytes=20MB Stdout log file size, default 50MBstdout_logfile_backups = 20; number of stdout log file backups, default is 10; stdout log file, which cannot be started normally when the specified directory does not exist, so you need to create a directory manually (supervisord will automatically create log files) stdout_logfile=/opt/apache-tomcat-8.0.35/logs/catalina.outstopasgroup=false Default is false. When a process is killed, whether to send stop signal to this process group, including child process killasgroup=false; default is false, and send kill signal to process group, including child process; include other configuration files [include] files = / etc/supervisor/config.d/*.ini; you can specify one or more configuration files that end with .ini; files = / opt/absolute/filename.ini / opt/absolute/*.ini foo.conf config??.ini Include example

4. Process management configuration parameters are not recommended to be written in the supervisord.conf file. Each process should write a configuration file and include it in the supervisord.conf file in the directory specified by include.

Create a / etc/supervisor/config.d directory to store the configuration files for process management

Mkdir / etc/supervisor/config.d

Here is an example of configuring a Tomcat process:

Cat / etc/supervisor/config.d/tomcat.ini [program:tomcat] command=/opt/apache-tomcat-8.0.35/bin/catalina.sh runstdout_logfile=/opt/apache-tomcat-8.0.35/logs/catalina.outautostart=trueautorestart=truestartsecs=5priority=1stopasgroup=truekillasgroup=true

5. Start the Supervisor service

Supervisord-c / etc/supervisor/supervisord.conf

Http://ip:9001 can be accessed by browsers now

You can also command to start and view the service:

[root@localhost supervisor] # supervisorctl restart tomcattomcat: stoppedtomcat: started [root@localhost supervisor] # supervisorctl statustomcat STOPPED Nov 19 11:22 AM

6. Turn on the self-startup configuration

Go to the / lib/systemd/system directory and create the supervisor.service file

Vim supervisor.service// file content: [Unit] Description=supervisorAfter= network.target [service] Type=forkingExecStart=/usr/bin/supervisord-c / etc/supervisor/supervisord.confExecStop=/usr/bin/supervisorctl $OPTIONS shutdownExecReload=/usr/bin/supervisorctl $OPTIONS reloadKillMode=processRestart=on-failureRestartSec=42s [Install] WantedBy=multi-user.target

Set up boot boot

Systemctl enable supervisor.servicesystemctl daemon-reload

Modify file permissions to 766

Chmod 766 supervisor.service

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 270

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report