supervisor安裝配置
阿新 • • 發佈:2017-12-21
supervisor系統環境: CentOS7 結尾的文件,內容如下
supervisor版本:supervisor-3.1.4-1.el7.noarch
安裝:
yum -y install supervisor
啟動服務:
supervisord -c /etc/supervisord.conf
用systemctl管理supervisord服務
進入目錄 /usr/lib/systemd/system/,增加文件 supervisord.service,來使得機器啟動的時候啟動supervisor,文件內容
# supervisord service for systemd (CentOS 7.0+) # by ET-CS (https://github.com/ET-CS) [Unit] Description=Supervisor daemon [Service] Type=forking ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown ExecReload=/usr/bin/supervisorctl $OPTIONS reload KillMode=process Restart=on-failure RestartSec=42s [Install] WantedBy=multi-user.target
激活開機啟動命令
systemctl enable supervisord.service
啟動supervisor進程
systemctl start supervisord.service
關閉supervisor進程
systemctl stop supervisord.service
如果修改了supervisor.service文件,可以通過reload命令來重新加載配置文件
systemctl reload supervisord.service
使用superviosr管理其他服務
下面是以supervisor管理.Net Core程序為例寫的一個配置文件
進入/etc/supervisord.d/創建一個以.ini
[program:Fastel.InvoiceService] ##Fastel.InvoiceService是服務名稱 command=dotnet Fastel.InvoiceService.dll --ENVIRONMENT Release ##啟動服務需要執行的命令 directory=/opt/Apps/Fastel.InvoiceService/latest/packages ##在哪個目錄下執行啟動服務的命令 user=user1 ##以user1用戶啟動Fastel.InvoiceService服務 stdout_logfile=/opt/Apps/Fastel.InvoiceService/logs/stdout.log ##標準輸出日誌路徑 stderr_logfile=/opt/Apps/Fastel.InvoiceService/logs/err.log ##錯誤日誌路徑 autostart=true ##改服務隨supervisor服務啟動而啟動 autorestart=true ##服務stop後自動重啟 #startsecs=5 #priority=1 #stopasgroup=true #killasgroup=true
supervisorctl 命令管理服務
supervisorctl status
查看正在守候的所有服務狀態
supervisorctl update
更新或者修改/etc/supervisord.d/下面的服務配置文件後,執行此命令重新加載配置
supervisorctl reload
重啟supervisor中所有程序
supervisorctl restart all
重啟supervisor中所有程序
supervisorctl restart service_name
重啟指定的服務
supervisorctl stop all
停止所有服務
supervisor安裝配置