用配置文件管理和守护普通进程,并提供 supervisorctl 控制接口。
Supervisor 是 Python 写的进程管理器:supervisord 作为守护进程启动子程序,按 autorestart 重启退出进程,把 stdout/stderr 写入日志,并通过 Unix socket/XML-RPC 暴露给 supervisorctl。它适合管理应用进程,但不是 init 系统,不能替代 systemd 处理开机顺序和系统级依赖。
配置为 INI:[program:name] 定义 command、directory、user、environment、autostart、autorestart、stdout_logfile;[unix_http_server] 和 [supervisorctl] 定义控制通道。程序必须以非守护方式前台运行,否则 supervisor 会认为它启动后立即退出。
# 前台启动便于排错,指定配置文件
supervisord -n -c /etc/supervisord.conf
# 查看状态、重载配置并应用变更
supervisorctl -c /etc/supervisord.conf status
supervisorctl -c /etc/supervisord.conf reread
supervisorctl -c /etc/supervisord.conf update
# 重启单个程序并跟踪日志
supervisorctl restart myapp
supervisorctl tail -f myapp
restart 不会重新读取文件,必须先 reread 再 update。--daemon/-d。environment。chmod/chown。合上页面,先回答,再展开对照。
[program:name] 配置后只执行 restart,为什么新配置没有生效?restart 不会重新读取配置文件,必须先 reread 再 update。--daemon/-d,让程序前台运行。environment。
小程序版
微信扫码,随时查命令