五月综合激情婷婷六月,日韩欧美国产一区不卡,他扒开我内裤强吻我下面视频 ,无套内射无矿码免费看黄,天天躁,日日躁,狠狠躁

新聞動態(tài)

3分鐘學(xué)會如何上手supervisor看門狗

發(fā)布日期:2021-12-27 16:16 | 文章來源:腳本之家

軟硬件環(huán)境

  • centos7.6.1810 64bit
cat /etc/redhat-release #查看系統(tǒng)版本
  • supervisor 3.4.0
  • python 2.7.5

supervisor簡介

supervisor是一個用python語言編寫的進程管理工具,它可以很方便的監(jiān)聽、啟動、停止、重啟一個或多個進程。當(dāng)一個進程意外被殺死,supervisor監(jiān)聽到進程死后,可以很方便的讓進程自動恢復(fù),不再需要程序員或系統(tǒng)管理員自己編寫代碼來控制。

supervisord安裝

yum install -y epel-release
yum install -y supervisor

啟動&開啟自啟

systemctl start supervisord
systemctl enable supervisord

其他命令:

systemctl stop supervisord #停止啟動
systemctl start supervisord #啟動
systemctl status supervisord #啟動狀態(tài)
systemctl reload supervisord #重載
systemctl restart supervisord #重啟

supervisor的web端

supervisor提供了基于web的控制,管理員可以通過在頁面上點點按鈕即可完成對進程的啟動、重啟等操作,甚是方便。

進入配置文件,開啟對web端的支持

vim /etc/supervisord.conf

如果提供給外部訪問,需要將port改為本機ip地址

#取消10-13行注釋,前面數(shù)字是行號
[inet_http_server]  ; inet (TCP) server disabled by default
port=192.168.26.121:9001 ; (ip_address:port specifier, *:port for all iface)
username=user  ; (default is no username (open server))
password=123  ; (default is no password (open server))

配置完成后重啟服務(wù)

systemctl restart supervisord

supervisord應(yīng)用配置

進入supervisord配置文件

cat /etc/supervisord.conf

通過配置文件最后一行看到

[include]
files = supervisord.d/*.ini

也就是說,我們所有的應(yīng)用配置文件都保存在這個目錄下,以.ini格式命名保存的,可以自行修改地址,但不要修改后綴

那我們來創(chuàng)建一個受監(jiān)控的應(yīng)用吧

創(chuàng)建測試python配置

創(chuàng)建一個名稱叫做python的應(yīng)用程序配置

vim /etc/supervisord.d/python.ini

配置文件內(nèi)容,其中command就是我們應(yīng)用程序啟動需要執(zhí)行的命令

[program:python] #這里的python就是我們顯示在web前端以及終端的監(jiān)控名稱
command=python /tmp/supervisordtest/test.py #我們要監(jiān)控的文件地址
autostart=true
autorestart=true
startsecs=1
startretries=3
redirect_stderr=true
stdout_logfile=/tmp/supervisordtest/access_python.log #日志地址,可自行配置目錄
stderr_logfile=/tmp/supervisordtest/error_python.log #日志地址,可自行配置目錄

創(chuàng)建test.py

mkdir /tmp/supervisordtest
vim /tmp/supervisordtest/test.py

程序內(nèi)容:開啟一個死循環(huán),不停的打印內(nèi)容

while True:
 print(100)

重啟supervisord使配置文件生效

systemctl restart supervisord

查看應(yīng)用是否正常啟動

1、命令查看

systemctl status supervisord

2、可視化web查看

web端可以重啟,停止,清理日志,查看日志等多個操作

supervisor相關(guān)的幾個命令

安裝完畢,會生成3個系統(tǒng)命令supervisorctl、supervisordecho_supervisord_conf

1.supervisord,運行supervisor時會啟動一個進程supervisord,它負責(zé)啟動所管理的進程,并將所管理的進程作為自己的子進程來啟動,而且可以在所管理的進程出現(xiàn)崩潰時自動重啟

2. supervisorctl是命令行管理工具,可以用來執(zhí)行 start 、stoprestart 等命令,來對這些子進程進行管理, 如

sudo supervisorctl start demoweb

其中demoweb是進程的名稱, 詳細的命令及說明見下面的這張表

命令 說明
supervisorctl start program_name 啟動某個進程
supervisorctl stop program_name 停止某個進程
supervisorctl restart program_name 重啟某個進程
supervisorctl status program_name 查看某個進程的狀態(tài)
supervisorctl stop all 停止全部進程 | \
supervisorctl reload 載入最新的配置文件,重啟所有進程
supervisorctl update 根據(jù)最新的配置,重啟配置更改過的進程,未更新的進程不受影響

3. echo_supervisord_conf

用來生成默認的配置文件(默認配置文件,內(nèi)容非常齊全且都有注釋,適合用時查閱,用法是這樣的

echo_supervisord_conf > test.conf

到此這篇關(guān)于3分鐘學(xué)會如何上手supervisor看門狗的文章就介紹到這了,更多相關(guān)3分鐘學(xué)會如何上手supervisor內(nèi)容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!

版權(quán)聲明:本站文章來源標注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。

實時開通

自選配置、實時開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時在線

客服
熱線

400-630-3752
7*24小時客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部