服务端配置:
1:通过以下命令生成主配置文件
echo_supervisord_conf > supervisord.conf
2:取消supervisord.conf文件注释
[include]
files = /etc/supervisor/conf.d/*.conf
3.启动supervisord
[root]$ > supervisord -c /etc/supervisor/supervisord.conf
4. 根据下方配置创建监控进程的配置文件
cd /etc/supervisor/conf.d/
5. 启动监控
supervisorctl start projectname
其中projectname配置文件里的Projectname
6. 重载配置文件
supervisorctl reload
7. 查看监控状态
supervisorctl status projectname
8. 停止监控
supervisorctl stop projectname
9. 重启监控
supervisorctl restart projectname
主配置文件啥也没改,就解开了include注释,并修改files参数到指定的目录
# /etc/supervisor/supervisord.conf
[include]
files = /etc/supervisor/conf.d/*.conf
在启动的时候要多查看日志,存在权限问题,目录不存在的情况,得一一解决
# /etc/supervisor/conf.d/process1.conf
[program:projectname] ;项目名
command=/home/admin/xx/bin/xxx.sh ; 被监控的进程路径
priority=1 ; 数字越高,优先级越高
numprocs=1 ; 启动几个进程
autostart=false ; 随着supervisord的启动而启动
autorestart=true ; 自动重启
startretries=10 ; 启动失败时的最多重试次数
exitcodes=0 ; 正常退出代码
stopsignal=KILL ; 用来杀死进程的信号
stopwaitsecs=10 ; 发送SIGKILL前的等待时间
redirect_stderr=true ; 重定向stderr到stdout
user=admin
stdout_logfile=/home/admin/logs/supervisor/xx.log ; stdout log path, NONE for none; default AUTO
stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10)
stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
stdout_events_enabled=false ; emit events on stdout writes (default false)
stdout_syslog=false ; send stdout to syslog with process name (default false)
stderr_logfile=/home/admin/logs/supervisor/xx.log ; stderr log path, NONE for none; default AUTO
stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
stderr_events_enabled=false ; emit events on stderr writes (default false)
stderr_syslog=false ; send stderr to syslog with process name (default false)
environment=A="1",B="2" ; process environment additions (def no adds)
serverurl=AUTO ; override serverurl computation (childutils)