一、背景
智慧营销平台中使用java spring boot 架构,在平台中运行了许多独立的jar程序。为方便日常运维,经研究之后,决定部署supervisor程序。
通过supervisor服务,可以实现:
1.Web页面集中监控多台机器微服务运行状态
2.通过Web页面可以启动、停止、重启指定服务
3.通过Web页面查看服务日志,节省时间
4.利用supervisor特性,监控java进程,解决内存溢出后服务宕机情况
二、启动supervisord服务
详细操作步骤见supervisor的安装部署及集群管理,本文重在实际记录操作过程。
1. 添加service服务
centos 6
在/etc/init.d/目录下放置supervisord 文件
supervisord
[root@localhost ~]# service supervisord status
supervisord (pid 2641) 正在运行...
设置开机启动
chkconfig supervisord on
centos 7
[root@localhost ~]# cd /usr/lib/systemd/system/
[root@localhost ~]# cp sshd.service supervisord.service
[root@localhost ~]# chmod 766 supervisord.service
[root@localhost ~]# systemctl enable supervisor.service
[root@localhost ~]# systemctl daemon-reload
2. 修改/etc/supervisor/supervisord.conf 配置文件
file=/tmp/supervisor.sock ; the path to the socket file
[inet_http_server] ; inet (TCP) server disabled by default
port=172.16.221.92:9001 ; ip_address:port specifier, *:port for all iface //通过web页面管理微服务程序
username=web1 ; default is no username (open server)
password=web123 ; default is no password (open server)
[superviso