小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

.Net core 守護(hù)進(jìn)程配置(supervisor)

 頭號(hào)碼甲 2021-03-17

1、介紹supervisor

Supervisor是用Python開發(fā)的一個(gè)client/server服務(wù),是Linux/Unix系統(tǒng)下的一個(gè)進(jìn)程管理工具,不支持Windows系統(tǒng)。它可以很方便的監(jiān)聽、啟動(dòng)、停止、重啟一個(gè)或多個(gè)進(jìn)程。用Supervisor管理的進(jìn)程,當(dāng)一個(gè)進(jìn)程意外被殺死,supervisort監(jiān)聽到進(jìn)程死后,會(huì)自動(dòng)將它重新拉起,很方便的做到進(jìn)程自動(dòng)恢復(fù)的功能,不再需要自己寫shell腳本來控制。

2、安裝環(huán)境

# 安裝 python環(huán)境
yum install python-setuptools
# 安裝 Supervisor
easy_install supervisor

3、配置Supervisor

# 新建配置目錄命令:
mkdir /etc/supervisor
#生成supervisor的初始化配置文件 :
echo_supervisord_conf > /etc/supervisor/supervisord.conf

編輯配置supervisord.conf

vim supervisord.conf 

主要是打開網(wǎng)絡(luò)訪問、默認(rèn)啟動(dòng)配置目錄

# 創(chuàng)建配置目錄
mkdir /etc/supervisor/conf.d
# 進(jìn)入目錄
cd conf.d

#創(chuàng)建一個(gè)WebApplication1.conf配置
vi WebApplication1.conf
# 創(chuàng)建程序啟動(dòng)配置
# 進(jìn)程名稱
[program:WebApplication1] 
# 執(zhí)行命令
command=dotnet WebApplication1.dll
# 執(zhí)行目錄
directory=/root/aspnetcoreapi
# 掉線是否自動(dòng)重啟
autorestart=true
# 日志信息
stderr_logfile=/var/log/WebApplication1.err.log
stdout_logfile=/var/log/WebApplication1.out.log
# 環(huán)境.Net core
environment=ASPNETCORE_ENVIRONMENT=Production
# 執(zhí)行用戶
user=root
stopsignal=INT

4、啟動(dòng)Supervisor

# 啟動(dòng)Supervisor
supervisord -c /etc/supervisor/supervisord.conf
#查看狀態(tài)
supervisorctl status

5、bash終端控制

#啟動(dòng)Supervisor
supervisord -c /etc/supervisor/supervisord.conf
# 查看狀態(tài)
supervisorctl status
# 停止某個(gè)服務(wù)
supervisorctl stop WebApplication1
# 開始某個(gè)服務(wù)
supervisorctl start WebApplication1
# 重啟某個(gè)服務(wù)
supervisorctl restart WebApplication1
# 重啟Supervisor
supervisorctl reload
# 修改Supervisor
supervisorctl update

6、將supervisor配置為開機(jī)自啟動(dòng)服務(wù)

# 編輯服務(wù)文件
vim /usr/lib/systemd/system/supervisord.service
# 內(nèi)容
[Unit]
Description=Supervisor
[Service]
Type=forking
PIDFile=/var/run/supervisord.pid
ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
# 保存退出 啟動(dòng)服務(wù)
systemctl enable supervisord
# 查看啟動(dòng)狀態(tài)  返回enabled成功
systemctl is-enabled supervisord

#成功之后,就可以使用如下命令管理supervisor服務(wù)了
# 停止
systemctl stop supervisord
# 啟動(dòng)
systemctl start supervisord
# 狀態(tài)
systemctl status supervisord
# 重載
systemctl reload supervisord
# 重啟
systemctl restart supervisord

我們最后也可以看到我們將進(jìn)程殺死之后馬上會(huì)啟動(dòng)一個(gè)新的進(jìn)程啟動(dòng)程序

最后我們可以通過我們配置的網(wǎng)絡(luò)地址訪問了,可以看到所有的程序方便管理

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多