新手,自己記錄一下
1、安裝supervisor。supervisor是基于Pyshon開發(fā)的,安裝supervisor時會自動安裝Python依賴項,所以不需要額外的安裝操作
# yun install supervisor
![](/d/20211016/317c2f8fc1a0bdc52ff273032053b95c.gif)
2、安裝成功后查看/etc下生成了相關(guān)文件和目錄
![](/d/20211016/70d539cd1350d979afaf3719b2bc366f.gif)
supervisord.conf 是默認(rèn)配置文件
supervisord.d是存放其他程序單獨配置文件的目錄
3、配置supervisord.conf
全部參數(shù)可以參考官方文檔,配置項太多,咱也看不懂,只需要修改一個地方即可,其它不變。
# vim /etc/supervisord.conf
![](/d/20211016/11a29b46ca6f141ed39b526bb57076f2.gif)
定位到文檔最后[include]項,將files = supervisord.d/*.ini修改為files = supervisord.d/*.conf,用來載入其它應(yīng)用程序的配置
![](/d/20211016/5af331474d67dbe599b24a752b0460f0.gif)
4、添加應(yīng)用程序(dotnet core)單獨配置文件
在supervisord.d目錄下新建配置文件
# touch /etc/supervisord.d/FirstApi.conf
打開文件添加以下內(nèi)容
[program:FirstApi]
#要執(zhí)行的命令
command=dotnet FirstApi.dll
#命令執(zhí)行的目錄
directory=/home/www/first
#環(huán)境變量
environment=ASPNETCORE__ENVIRONMENT=Production
#進(jìn)程執(zhí)行的用戶身份<br> user=root<br> stopsignal=INT
#是否自動啟動
autostart=true
#是否自動重啟
autorestart=true
#自動重啟間隔 秒
startsecs=1
#標(biāo)準(zhǔn)錯誤日志
stderr_logfile=/var/log/FirstApi.err.log
#標(biāo)準(zhǔn)輸出日志
stdout_logfile=/var/log/FirstApi.out.log
5、重啟supervisor服務(wù)
# supervisord -c /etc/supervisord.conf
如果提示:Another program is already listening on a port that one of our HTTP servers 則表示此服務(wù)已經(jīng)在運(yùn)行中,可以通過一下步驟重新啟動服務(wù)
#進(jìn)入控制臺
# supervisorctl
#重新讀取配置
reread
#更新配置
update
#開始所有配置
start all
#成功后查看狀態(tài)
status
![](/d/20211016/21766475fcddf787bb992f591e37239f.gif)
此時再次訪問程序地址,發(fā)現(xiàn)項目已經(jīng)成功運(yùn)行起來!
到此這篇關(guān)于centos7下安裝并配置supervisor守護(hù)程序的操作方法的文章就介紹到這了,更多相關(guān)centos7安裝supervisor內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!