supervisor是什么?
supervisor是用Python语言开发的一个client/server服务,是Linux/unix系统下的一个进程管理工具。它是可以很方便的监听、启动、停止、重启一个或多个进程。用Supervisor管理的进程,当一个进程意外被杀死,supervisor监听到进程死后,会自动将它拉起来,很方便的做到进程自动恢复的功能。
supervisor安装
1、查看Linux版本:
cat /etc/redhat-release
2、安装命令:
[root@localhost /]# yum install epel-release
[root@localhost /]# yum install -y supervisor
[root@localhost /]# systemctl enable supervisord # 开机自启动
[root@localhost /]# systemctl start supervisord # 启动supervisord服务
[root@localhost /]# systemctl status supervisord # 查看supervisord服务状态
[root@localhost /]# ps -ef|grep supervisord # 查看是否存在supervisord进程
3、安装成功后,在/etc下面有一个目录/supervisord.d;
4、有一个主配置文件supervisord.conf,supervisor监控多个不同的应用,为了方便统一管理,在/etc/supervisord.d/conf/下面配置每一个应用的配置文件;
supervisord.conf配置:
5、在/etc/supervisord.d/conf建立java应用配置文件,起名为springboot.hook.conf,配置内容如下所示:
[program:cltxpay.auth]
command=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64//bin/java -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/usr/cltx/cltxpay-auth/logs/java_heapdump.hprof -XX:-UseLargePages -Djava.ext.dirs=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64//jre/lib/ext:/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64//lib/ext -Xloggc:/usr/cltx/cltxpay-auth/logs/cltxpay_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -jar /usr/cltx/cltxpay-auth/lib/cltxpay-auth.jar --spring.config.location=file:/usr/cltx/cltxpay-auth/conf/ --logging.config=/usr/cltx/cltxpay-auth/conf/logback-spring.xml --server.max-http-header-size=524288 cltxpay.auth
user=root
directory=/usr/cltx/
autorestart=true
redirect_stderr=true
stdout_logfile=/usr/cltx/supervisor/auth.log
loglevel=info
environment=MALLOC_ARENA_MAX=“1”
stopasgroup = true
killasgroup = true