Supervisor最佳實踐

[TOC]

Supervisor最佳實踐

1、簡介

Supervisor是一個客戶端/服務器系統(tǒng),允許其用戶在類UNIX操作系統(tǒng)上控制許多進程。
它可以使進程(非守護進程)以守護進程的方式運行。

2、安裝

官網(wǎng)介紹了多種安裝方式:

  • yum
  • pip
  • 下載安裝包

詳見:官方安裝教程:(http://www.supervisord.org/installing.html)

建議用系統(tǒng)工具安裝,開機會自動啟動。
Centos 用 yum,Ubuntu 用 apt-get 。
其他安裝方式可以用chkconfig 設置開機啟動。

yum install supervisor

3、使用流程

安裝完成后有以下三個命令

  • echo_supervisord_conf 生成配置文件模板
  • supervisord supervisor 服務端命令
  • supervisorctl supervisor 客戶端命令

3.1 生成配置文件

echo_supervisord_conf > supervisord.conf

配置文件存放建議:
Supervisord 相關配置放 /etc/supervisord.conf ;
/etc/supervisord.conf 中 [include] 配置 /etc/supervisord.d/*.ini

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

/etc/supervisord.d/.ini 可以配置多個*程序。
可以用 echo_supervisord_conf生成配置文件,只截取[program:sample]的相關配置。
程序具體配置參考文檔。

Supervisor 配置文件查找順序:

  1. $CWD/supervisord.conf
  2. $CWD/etc/supervisord.conf
  3. /etc/supervisord.conf
  4. /etc/supervisor/supervisord.conf (since Supervisor 3.3.0)
  5. ../etc/supervisord.conf (Relative to the executable)
  6. ../supervisord.conf (Relative to the executable)

3.2 運行

# 啟動 Supervisord 服務
service supervisord start

# 查看運行狀態(tài)
supervisorctl status 

# 重啟
supervisorctl reload|restart
image.png
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容