## 安装supervisorctl步骤
yum install supervisor
### 开机自启动
systemctl enable supervisord
### 启动supervisord服务
systemctl start supervisord
### 查看supervisord服务状态
systemctl status supervisord
### 查看是否存在supervisord进程
ps -ef|grep supervisord
## 配置过程
### 添加文件
cd /etc/supervisord.d
touch elasticsearch.conf
touch skywalking-agent.conf
touch php-fpm.conf
### 守护 elasticsearch
[program:elasticsearch]
command = /data/soft/elasticsearch-6.8.16/bin/elasticsearch
autostart = true
startsecs = 5
autorestart = true
startretries = 3
user = elastic
environment=JAVA_HOME=/data/soft/jdk1.8.0_291
stdout_logfile = /var/log/supervisor/elasticsearch.out
stderr_logfile = /var/log/supervisor/elasticsearch.err
### 守护 skywalking
[program:skywalking-agent]
command = /usr/local/bin/sky-php-agent --grpc=127.0.0.1:11800 --sky-version=8 --socket=/tmp/sky-agent.sock
autostart = true
startsecs = 5
autorestart = true
startretries = 3
user = root
stdout_logfile = /var/log/supervisor/skywalking-agent.out
stderr_logfile = /var/log/supervisor/skywalking-agent.err
### 守护 PHP-FPM
[program:php-fpm]
command = /usr/sbin/php-fpm --fpm-config /etc/php-fpm.conf
autostart = true
startsecs = 5
autorestart = true
startretries = 3
user = root
stdout_logfile = /var/log/supervisor/php-fpm.out
stderr_logfile = /var/log/supervisor/php-fpm.err
此时启动 php-fpm 会报一个错误,查看 supervisorctl 错误日志
[10-Jun-2021 09:45:38] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98)
[10-Jun-2021 09:45:38] ERROR: FPM initialization failed
[10-Jun-2021 09:45:42] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98)
[10-Jun-2021 09:45:42] ERROR: FPM initialization failed
php-fpm 进程默认是以 daemon 方式启动的,而 Supervisor 文档 的说明是,使用 supervisor 监护进程时,被监护的进程不能是守护进程。
编辑 /etc/php-fpm.conf ,找到 daemonize 改为 no
编辑完后执行更新配置,再次启动后执行 killall php-fpm,php-fpm会重新启动
supervisorctl update
### 更新配置
supervisorctl update
### 查看进程状态
supervisorctl status
### 停止守护
supervisorctl stop skywalking-agent
### 启动守护
supervisorctl start skywalking-agent