Centos7.x 安装 Supervisord
?
?
【環(huán)境】
系統(tǒng):Centos 7.3
軟件:supervisord
?
【安裝Supervisord】
yum install epel-release yum install -y supervisor【設(shè)置開啟自啟】
systemctl enable supervisord【Supervisord管理命令】
systemctl stop supervisord systemctl start supervisord systemctl status supervisord systemctl reload supervisord systemctl restart supervisord【修改配置文件,使Supervisord可以在web端顯示】
vim /etc/supervisord.conf
#取消10-13行注釋,前面數(shù)字是行號 10 [inet_http_server] ; inet (TCP) server disabled by default 11 port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface) 12 username=user ; (default is no username (open server)) 13 password=123 ; (default is no password (open server))【監(jiān)控】
然后設(shè)置監(jiān)控文件以及腳本等
比如我們創(chuàng)建一個死循環(huán),讓腳本來監(jiān)控,這里拿python來說吧
在home目錄下創(chuàng)建一個while循環(huán)的py文件
vim /home/test.py
while True:print(100)這個文件一直打印100,如果不強(qiáng)制終止,則不會停止,接下來配置supervisord。我們可以通過配置文件最后一行看到
cat /etc/supervisord.conf
[include] files = supervisord.d/*.ini也就是說,我們所有的配置文件都保存在這個目錄下,以.ini格式命名保存的,可以自行修改地址,但不要修改后綴,那我們來創(chuàng)建supervisor文件吧
【創(chuàng)建Supervisord文件】
vim /etc/supervisord.d/python.ini
[program:python] #這里的python就是我們顯示在web前端以及終端的監(jiān)控名稱 command=python /home/test.py #我們要監(jiān)控的文件地址 autostart=true autorestart=true startsecs=1 startretries=3 redirect_stderr=true stdout_logfile=/etc/supervisord.log/access_python.log #日志地址,可自行配置目錄 stderr_logfile=/etc/supervisord.log/error_python.log #日志地址,可自行配置目錄【啟動Supervisord】
systemctl start supervisord 查看是否啟動 systemctl status supervisord注:如果啟動成功后無法登陸web端,則允許9001端口通過防火墻或者關(guān)閉防火墻,關(guān)閉selinux,把supervisord.conf中的port=127.0.0.1:9001中的127.0.0.1修改成IP地址重啟服務(wù)進(jìn)行訪問
【W(wǎng)eb端登陸】
?
?【登陸成功】
?
?
登陸之后,會出現(xiàn)如下界面,可以對該文件進(jìn)行一些操作,打開、停止、查看日志、清除日志
?
轉(zhuǎn)載于:https://www.cnblogs.com/willamwang/p/11447404.html
總結(jié)
以上是生活随笔為你收集整理的Centos7.x 安装 Supervisord的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux ``与 ''区别
- 下一篇: 计划工程师dadafksjh