supervisor 如何在 centos 7 启动时自动运行?

【字号: 日期:2022-08-12浏览:33作者:雯心

问题描述

supervisor 是用 yum install supervisor 进行安装的,安装后发现如果服务器重启,需要手动运行 supervisord 后才能执行 supervisor 管理的服务。

在官网 Running supervisord automatically on startup 这篇文章中描述,因为我不是用 'distribution-packaged' 安装的,所以不会被自动添加进去(用 easy_install supervisor 安装不成功)

同时还提供了第三方脚本,但是不知道怎么用 https://github.com/Supervisor/initscripts

请问,如何让 supervisor 在 centos 7 系统重启后自动运行呢?

问题解答

回答1:

centos 7 用 systemctl 进行管理,只要运行下面的代码就可以了:

$ systemctl enable supervisord.service# 运行结果Created symlink from /etc/systemd/system/multi-user.target.wants/supervisord.service to /usr/lib/systemd/system/supervisord.service.

如果还是启动不起来,可以编辑上面路径里的 supervisord.service 文件,替换成 github 的那个 centos-systemd-etcs:

# supervisord service for sysstemd (CentOS 7.0+)# by ET-CS (https://github.com/ET-CS)[Unit]Description=Supervisor daemon[Service]Type=forkingExecStart=/usr/bin/supervisordExecStop=/usr/bin/supervisorctl $OPTIONS shutdownExecReload=/usr/bin/supervisorctl $OPTIONS reloadKillMode=processRestart=on-failureRestartSec=42s[Install]WantedBy=multi-user.target回答2:

CentOS7是systemd了. 把那个repo的centos-systemd-etcs这个unit装到/etc应该就可(具体路径自己查).

不过yum怎么就不是distribution-packaged version了? 这rpm哪来的? rpm -ql supervisor的结果是啥?

回答3:

yum安装深坑,建议卸载替换安装方式

相关文章: