Supervisor安裝與配置

不·一發表於2019-02-15

注:Supervisor目前只能執行在python2.x 一、安裝 1.1、使用apt-get安裝

$ sudo apt-get install supervisor
複製程式碼

1.2、使用pip安裝

$ sudo pip install  supervisor
複製程式碼

安裝之後:會產生三個可執行程式,supervisord supervisorctl echo_supervisor_conf,這三個程式分別是:守護程式、supervisor客戶端、建立預設supervisor的配置檔案。 二、配置 2.1、使用apt-get安裝後的配置 對於使用apt-get1安裝成功後,預設的配置都已經生成,配置檔案路徑為:

$ /etc/supervisor
複製程式碼

該目錄下所有檔案:

$ ls
conf.d  supervisord.conf
複製程式碼

其中supervisord.conf是supervisord的配置檔案 conf.d是一個目錄,我們可以將我們的程式配置移到改目錄下 分檔案組織 supervisord.conf配置檔案的內容為:

; supervisor config file

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = /etc/supervisor/conf.d/*.conf
複製程式碼

在conf.d資料夾下建立檔案 service-evernote.conf

[program:service-evernote]
autorestart=True
redirect_stderr=True
command=/opt/services/evernote/evernote/bin/dock-server dock_evernote -s gevent -b 0.0.0.0:5000
user=root
autostart=True
directory=/opt/services/evernote/evernote
stdout_logfile=/opt/services/evernote/evernote/evernote.log
複製程式碼

執行

sudo supervisorctl 
複製程式碼

檢視執行的服務

配置檔案載入

sudo supervisorctl reload
複製程式碼

相關文章