本文最后更新于:6 天前
安装 supervisor 1 yum install -y supervisor
设置开机启动 1 systemctl enable supervisord
启动 supervisor
查看状态 1 systemctl status supervisord
修改配置文件 1 vim /etc/supervisord.conf
#开启web界面访问 把[inet_http_server]模块的注释去掉,并修改IP、用户名与密码 1 2 3 4 [inet_http_server] ; inet (TCP) server disabled by default port=10.64.56.159:9001 ; (ip_address:port specifier, *:port for all iface) username=*** ; (default is no username (open server)) password=*** ; (default is no password (open server))
重新加载配置文件 1 ~~supervisorctl reload~~
php laravel 配置 Supervisor示例 #修改 /etc/supervisord.conf 文件内容 1 2 3 ; files = supervisord.d/*.ini files = /etc/supervisord.d/conf.d/*.conf
在 /etc/supervisord.d/下创建文件test.conf,内容如下: 1 2 3 4 5 6 7 8 9 10 11 [program:sync_goods_to_es] process_name=%(program_name)s_%(process_num)02dcommand =php artisan command.sync.goods.to.es ;被监控的进程路径 priority=999 ;优先级,数值越低越先启动而越后关闭 (default 999) autostart=true ;随着supervisord的启动而启动 autorestart=true ;自动重启 user=root ;用哪个用户启动进程,默认是root numprocs=1 ;启动几个进程 redirect_stderr=true ;重定向stderr到stdout stdout_logfile=/data0/log-data/service.log;
stdout 日志文件,需要注意当指定目录不存在时无法正常启动,所以需要手动创建目录(supervisord 会自动创建日志文件)
执行命令使配置文件生效 1 2 3 supervisorctl reload supervisorctl update
如果修改了 /etc/supervisord.conf,重启 supervisord 1 systemctl restart supervisord
常用命令 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 systemctl start supervisord systemctl stop supervisord systemctl status supervisord supervisorctl reread supervisorctl update supervisorctl reload supervisorctl shutdown supervisorctl stop|start program_name supervisorctl status