supervisor守護服務碰見的幾個坑

近期在ubunt系列服務器上碰見了supervisor的幾個坑,因此將服務守護都已經切換到systemd。linux

坑1、資源限制配額不跟隨limits.conf

1.咱們在用supervisor守護一個服務A的時候,發現由supervisor拉起的服務文件描述符未跟隨系統limits設置。web

[program:servicea]
username=root
command = bash /etc/servicea.sh
autostart = true
stopasgroup = true
autorestart = true
startsecs = 3
stdout_logfile = /var/log/servicea.log

cat /proc/$(ps ax|grep servicea|grep -v grep|awk {print $1})/limits |grep open
Max open files            1024                 4096                 files

發現最大的文件描述符仍是1024,對於系統初始化優化的時候,咱們都會更改/etc/security/limits.confbash

root  soft   nofile  65535
root  hard   nofile  65535
root  soft   nproc    65535
root  hard   nproc    65535
* soft   nproc    65535
* hard   nproc    65535
* soft   nofile  65535
* hard   nofile  65535
root@sklinux.com:~# ulimit -SHn
65535

或者比上訴值更大,然而supervisor守護服務,資源限制配額不跟隨limits.conf。服務器

坑2、supervisor守護prometheus服務的時候吃掉重要參數

2.咱們在用supervisor守護prometheus服務的時候發現,重要參數被「吃」掉。優化

supervisor中prometeus配置以下:spa

#爲方便查看作了換行處理
[program:prometheus]
username=root
directory=/opt/prometheus/data
command = /opt/prometheus/prometheus 
--config.file=/opt/prometheus/prometheus.yml
--web.listen-address="8.8.8.8:9090" 
--storage.tsdb.path="/opt/prometheus/data/"
--storage.tsdb.retention.time=90d --web.enable-lifecycle 
autostart = flase
stopasgroup = true
autorestart = true
startsecs = 3
stdout_logfile = /var/log/prometheus.log

咱們發現每次拉起服務的時候,–storage.tsdb.path=「/opt/prometheus/data/「參數未生效,數據始終默認保存在/data下。 而後經過rest

command = /start.prometheus.sh


start.prometheus.sh 內容:
#爲方便查看作了換行處理
/opt/prometheus/prometheus 
--config.file=/opt/prometheus/prometheus.yml
--web.listen-address="8.8.8.8:9090"
--storage.tsdb.path="/opt/prometheus/data/"
--storage.tsdb.retention.time=90d --web.enable-lifecycle

一樣,參數無效。可是經過手工執行/start.prometheus.sh 能夠將數據存儲路徑存在目標路徑/opt/prometheus/data/中。
後來,咱們將上訴服務切換爲systemd守護,一切ok了! 比較:日誌

Systemd

a.穩定可靠
b.支持 Before/After 依賴機制 c.支持 Notify 機制
d.支持基於 cgroup 的資源限制進程

Supervisord

a.支持經過 priority 配置進程啓動順序
b.日誌友好方便查閱
c.跨平臺使用
d.擴展開發友好,守護業務系統
e.可是bug多,資源限制不足資源

 

https://www.sklinux.com/

相關文章
相關標籤/搜索