使用supervisord 来守护 nginx进程

supervisord 简介:

Supervisord 是用 Python 实现的一款的进程管理工具,supervisord 要求管理的程序是非 daemon 程序,supervisord 会帮你把它转成 daemon 程序,因此如果用 supervisord 来管理进程,进程需要以非daemon的方式启动。

例如:管理nginx 的话,必须在 nginx 的配置文件里添加一行设置 daemon off 让 nginx 以非 daemon 方式启动。
安装,配置过程 参考了 胡伟煌 Linux 学习笔记 非常详细,非常感谢
https://www.bookstack.cn/read/huweihuang-linux-notes/tools-supervisor-usage.md
另外其他资料上说 在编写 supervisord 管理nginx的配置文件(就是supervisord 通过这个配置文件来启动nginx)上说,
nginx的启动命令 要加上 -g ‘daemon off;’ 但是我尝试了之后,发现这样并不能启动nginx, 我还是通过改变 nginx 自身的配置文件 比如:
/usr/local/nginx/conf/nginx.conf

...
daemon off;
...
 
events {
    ...
}
 
http {
    ...
}

另外 将 supervisord加入开机启动项:

systemctl enable supervisord

参考链接:https://blog.csdn.net/cxu123321/article/details/104766471/

你可能感兴趣的:(运维)