当前位置: 代码迷 >> 综合 >> supervisord 监听多服务
  详细解决方案

supervisord 监听多服务

热度:90   发布时间:2024-02-09 17:09:50.0

安装

centos 7 : yum install supervisor -y

centos 8 : dnf install supervisor -y

容器安装: apk add --no-cache --virtual supervisor (需要公网访问权限,FROM采用 alpine:3.9)

 

配置文件

默认目录:/etc/supervisor.conf /etc/supervisor.d/*.ini

*.ini 配置方法

[program:nginx]       ;程序名称,终端控制时需要的标识

command=nginx      ; 运行程序的命令 (绝对路径最好)

directory=/opt           ; 命令执行的目录 , 绝对路径可删除此项

autorestart=true       ; 程序意外退出是否自动重启 stderr_logfile=/var/log/nginx.err.log ; 错误日志文件

注:日志产生过快,容易导致容器占用存储过大

stdout_logfile=/var/log/nginx.out.log        ; 输出日志文件

environment=ASPNETCORE_ENVIRONMENT=Production ; 进程环境变量

user=root                  ; 进程执行的用户身份

stopsignal=INT

 

运行方式:

supervisord -nc /etc/supervisord.conf

-c :  指定配置文件

-n :  前台运行(默认后台运行)

-v : 查看版本

-u : 指定启动用户

 

设置开机自启:

[Unit]

Description=Supervisor daemon

[Service]

Type=forking

ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf

ExecStop=/usr/bin/supervisorctl shutdown

ExecReload=/usr/bin/supervisorctl reload

KillMode=process

Restart=on-failure

RestartSec=42s

[Install]

WantedBy=multi-user.target

  相关解决方案