Supervisor 容許其用戶在UNIX類操做系統上控制多個進程。 塊以下:html
方便python
須要爲每一個進程實例編寫rc.d腳本一般是不方便的。 rc.d腳本是進程初始化/自動啓動/管理的經常使用形式,但寫入和維護可能會很痛苦。此外,rc.d腳本不能自動從新啓動崩潰的進程,而且許多程序在崩潰時不會正常從新啓動。Supervisord啓動進程做爲其子進程,並能夠配置爲在崩潰時自動從新啓動它們。它也能夠自動配置爲在其自身的調用中啓動進程。linux
準確性web
在UNIX上的進程一般很難得到準確的上/下狀態。Pidfiles常常說謊。Supervisord啓動進程做爲子進程,因此它老是知道它的子進程的真正的上/下狀態,能夠方便地查詢這些數據。sql
進程組shell
進程一般須要以組爲單位啓動和中止,有時甚至在「優先級順序」中。人們經常難以解釋這一點。Supervisor 容許您爲進程分配優先級,並容許用戶經過supervisorctl客戶端發出命令,如「所有啓動」和「從新啓動全部」,以預分配的優先級順序啓動它們。此外,進程能夠分組爲「進程組」,一組邏輯關聯進程能夠做爲一個單元中止並啓動。django
簡單centos
Supervisor經過簡單的INI風格的配置文件進行配置,易於學習。它提供了許多每一個進程選項,使您的生活更容易,如從新啓動失敗的進程和自動日誌輪換。api
集中瀏覽器
進程能夠單獨或分組控制。您能夠配置Supervisor以提供本地或遠程命令行和Web界面。
高效
Supervisor經過fork / exec啓動其子進程,子進程不進行後臺進程。
擴展性強
Supervisor有一個簡單的事件通知協議,用任何語言編寫的程序均可以用來管理它,還有一個用於控制的XML-RPC接口。它還使用能夠由Python開發人員利用的擴展點構建。
兼容
supervisor除Windows以外。它在Linux,Mac OS X,Solaris和FreeBSD上進行了測試和支持。它徹底用Python編寫,所以安裝不須要C編譯器。
穩定性
Supervisor已經存在多年,並已在許多服務器上使用。
supervisord
supervisord服務端程序。它負責在本身的調用中啓動子程序,響應客戶端的命令,從新啓動崩潰或退出的子進程,記錄其子進程stdout和stderr 輸出,以及生成和處理對應於子進程生命週期中的「事件」。
配置文件。這一般位於/etc/supervisord.conf中。此配置文件是「Windows-INI」樣式的配置文件。適當的文件系統權限來保護此文件很是重要,由於它可能包含未加密的用戶名和密碼。
supervisorctl
supervisor的命令行客戶端名爲 supervisorctl。它爲supervisor提供的功能提供了一個相似shell的界面。從supervisorctl,用戶能夠鏈接到不一樣的 supervisord,中止和啓動的子進程,並得到運行的進程的列表supervisord。
命令行客戶端經過UNIX域套接字或Internet(TCP)套接字與服務器通訊。服務器能夠斷言客戶端的用戶在容許他執行命令以前應該出現認證憑證。客戶端進程一般使用與服務器相同的配置文件,但其中具備[supervisorctl]部分的任何配置文件均可以正常工做。
Web Server
Web Server 能夠經過瀏覽器訪問查看和控制進程狀態,在置文件的[inet_http_server]塊裏配置,訪問服務器URL(例如http:// localhost:9001 /)以經過Web界面查看和控制進程狀態。
XML-RPC接口
服務於Web UI的相同的HTTP服務器提供了一個XML-RPC接口,可用於詢問和控制supervisor及其運行的程序。請參閱XML-RPC API文檔。
安裝Supervisor的方法有不少種 具體請到Supervisor 官網
連接以下 http://supervisord.org/installing.html
YUM安裝Supervisor (centos6 測試過用yum安裝有問題, 建議使用源碼安裝方法)
1
2
3
4
5
|
[root@wuguiyunwei ~]# yum -y install epel-release wget
[root@wuguiyunwei ~]# yum -y install supervisor
[root@wuguiyunwei ~]# echo_supervisord_conf > /etc/supervisord.conf
[root@wuguiyunwei ~]# systemctl start supervisord
[root@wuguiyunwei ~]# systemctl status supervisord
|
我們此次使用源碼安裝 Supervisor
安裝setuptools
1
2
3
4
5
6
|
[root@wuguiyunwei ~]# yum -y install epel-release
[root@wuguiyunwei ~]# yum -y install python-setuptools
[root@wuguiyunwei ~]# wget http://source.goyun.org:8000/source/meld3/meld3-0.6.10.tar.gz
[root@wuguiyunwei ~]# tar zxf meld3-0.6.10.tar.gz
[root@wuguiyunwei ~]# cd meld3-0.6.10
[root@wuguiyunwei meld3-0.6.10]# python setup.py install
|
下載supervisor源碼包 && 解壓 && 安裝 && 生成模板文件 && 啓動
1
2
3
4
5
6
7
8
9
10
|
[root@wuguiyunwei src]# wget http://source.goyun.org:8000/source/supervisor/supervisor-3.3.2.tar.gz
[root@wuguiyunwei src]# tar zxf supervisor-3.3.2.tar.gz
[root@wuguiyunwei src]# cd supervisor-3.3.2
[root@wuguiyunwei supervisor-3.3.2]# python setup.py install
[root@wuguiyunwei /]# echo_supervisord_conf > /etc/supervisord.conf
[root@wuguiyunwei /]# supervisord -c /etc/supervisord.conf
[root@wuguiyunwei /]# ps aux | grep supervisord
root 2518 0.0 0.3 216576 11820 ? Ss 16:11 0:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
[root@wuguiyunwei /]# supervisord -v
3.3.2
|
; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
; - Shell expansion ("~" or "$HOME") is not supported. Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".
; - Quotes around values are not supported, except in the case of
; the environment= options as shown below.
; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
; - Command will be truncated if it looks like a config file comment, e.g.
; "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
[unix_http_server]
file=/tmp/supervisor.sock ; socket 文件路徑
;chmod=0700 ; socket 文件 模式 (默認 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; 使用supervisorctl鏈接的用戶
;password=123 ; 上條用戶的密碼
;[inet_http_server] ; Web Server和遠程的supervisorctl 配置塊(默認關閉)
;port=127.0.0.1:9001 ; 監聽的地址和端口
;username=user ; 登陸時用的用戶
;password=123 ; 上條用戶的密碼
[supervisord]
logfile=/tmp/supervisord.log ; supervisord進程日誌路徑
logfile_maxbytes=50MB ; supervisord進程日誌的大小 當超過50M時,會生成一個新的日誌( 0 表示不限制)
logfile_backups=10 ; 日誌文件保持的數量,啓動supervisor時 會自動建立10個buckup文件,用於log rotate ( 0 表示不限制)
loglevel=info ; 日誌級別
pidfile=/tmp/supervisord.pid ; supervisord的pid文件路徑。
nodaemon=false ; 若是是true,supervisord進程將在前臺運行 默認爲false(後臺運行)
minfds=1024 ; 這個是最少系統空閒的文件描述符,低於這個值supervisor將不會啓動
minprocs=200 ; 最小可用的進程描述符,低於這個值supervisor也將不會正常啓動
;umask=022 ; 進程建立文件的掩碼 (默認 022)
;user=chrism ; 該參數指定的用戶也能夠對supervisord進行管理
;identifier=supervisor ; supervisord的標識符
;directory=/tmp ; 當supervisord以守護進程運行的時候,啓動supervisord進程以前,會先切換到這個目錄
;nocleanup=true ; false的時候 supervisord進程啓動的時候 會在把之前子進程產生的日誌文件(路徑爲AUTO的狀況下)清除掉(true不清除)
;childlogdir=/tmp ; 當子進程日誌路徑爲AUTO的時候,子進程日誌文件的存放路徑 (默認 $TMP)
;environment=KEY="value" ; 這個是用來設置環境變量的,supervisord在linux中啓動默認繼承了linux的 環境變量,在這裏能夠設置supervisord進程特有的其餘環境變量supervisord啓動子進程時,子進程會拷貝父進程的內存空間內容。 因此設置的這些環境變量也會被子進程繼承 (默認不設置)
;strip_ansi=false ; 這個選項若是設置爲true,會清除子進程日誌中的全部ANSI(\n,\t) 序列
[rpcinterface:supervisor] ; 這個選項是給XML_RPC用的,果想使用supervisord或者web server 必需要開啓
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; supervisorctl本地鏈接supervisord,本地UNIX socket
;serverurl=http://127.0.0.1:9001 ; supervisorctl遠程鏈接supervisord的時候,用到的地址和端口
;username=chris ; 鏈接登陸的用戶名
;password=123 ; 密碼
;prompt=mysupervisor ; 輸入用戶名密碼時候的提示符 默認:mysupervisor
;history_file=~/.sc_history ; 指定歷史命令的文件
;[program:theprogramname] ; 案例 [program:給要管理進程起的一個名字]
;command=/bin/cat ; 要執行的進程 可帶參數 $1 $2 $3 注意!! 執行的進程不能是守護進程 ! !
;process_name=%(program_name)s ; 進程名 下條numprocs參數爲1,就不用管這個參數 默認值%(program_name)s也就是上面的那個program冒號後面的名字
;numprocs=1 ; 啓動進程的數目。當不爲1時,就是進程池的概念,默認爲1
;directory=/tmp ; 進程運行前,會前切換到這個目錄
;umask=022 ; 進程掩碼 (default None)
;priority=999 ; 子進程啓動關閉優先級,優先級低的,最早啓動,關閉的時候最後關閉 (default 999)
;autostart=true ; 設置爲true 子進程將在supervisord啓動後被自動啓動
;startsecs=1 ; 設置子進程啓動多少秒以後,此時狀態若是是running,則咱們認爲啓動成功了
;startretries=3 ; 進程啓動失敗後,最大嘗試啓動的次數 當超過3次後,supervisor將把此進程的狀態置爲FAIL
;autorestart=unexpected ; 設置子進程掛掉後自動重啓的狀況,有三個選項,false,unexpected和true。若是爲false的時候,不管什麼狀況下,都不會被從新啓動,若是爲unexpected,只有當進程的退出碼不在上面的exitcodes裏面定義的退出碼的時候,>纔會被自動重啓。當爲true的時候,只要子進程掛掉,將會被無條件的重啓
;exitcodes=0,2 ; 注意和上面的的autorestart=unexpected對應 exitcodes裏面的定義的退出碼是expected的。
;stopsignal=QUIT ; 進程中止信號,能夠爲TERM, HUP, INT, QUIT, KILL, USR1, or USR2等信號 默認爲TERM 當用設定的信號去殺掉進程,退出碼會被認爲是expected
;stopwaitsecs=10 ; 這個是當咱們向子進程發送stopsignal信號後,到系統返回信息給supervisord,所等待的最大時間。 超過這個時間,supervisord會向該子進程發送一個強制kill的信號(默認10秒)
;stopasgroup=false ; 這個東西主要用於,supervisord管理的子進程,這個子進程自己還有子進程 那麼咱們若是僅僅幹掉supervisord的子進程的話,子進程的子進程有可能會變成孤兒進程 因此我們能夠設置可個選項,把整個該子進程的整個進程組都幹掉 設置爲true的話,通常killasgroup也會被設置爲true 該選項發送的是stop信號(def false)
;killasgroup=false ; 這個和上面的stopasgroup相似,不過發送的是kill信號(def false)
;user=chrism ; 若是supervisord是root啓動,咱們在這裏設置這個非root用戶,能夠用來管理該program 默認不設置
;redirect_stderr=true ; 爲true,則stderr的日誌會被寫入stdout日誌文件中 (default false)
;stdout_logfile=/a/path ; 子進程的stdout的日誌路徑,能夠指定路徑,AUTO,none等三個選項 設置爲none的話,將沒有日誌產生。設置爲AUTO的話,將隨機找一個地方成日誌文件,並且當supervisord從新啓動的時候,之前的日誌文件會被清空。當 redirect_stderr=true的時候,sterr也會寫進這個日誌文件
;stdout_logfile_maxbytes=1MB ; 日誌文件最大大小,和[supervisord]中定義的同樣 (default 50MB)
;stdout_logfile_backups=10 ; 和[supervisord]定義的同樣 (0 means none, default 10)
;stdout_capture_maxbytes=1MB ; 這個東西是設定capture管道的大小,當值不爲0的時候,子進程能夠從stdout發送信息,而supervisor能夠根據信息,發送相應的event (default 0)
;stdout_events_enabled=false ; 爲ture的時候,當子進程由stdout向文件描述符中寫日誌的時候,將觸發supervisord發送PROCESS_LOG_STDOUT類型的event(default false)
;stderr_logfile=/a/path ; 設置stderr寫的日誌路徑,當redirect_stderr=true。這個就不用設置了,設置了也是白搭。由於它會被寫入stdout_logfile的同一個文件中 default AUTO(隨便找個地存,supervisord重啓被清空)
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
;stderr_events_enabled=false ; emit events on stderr writes (default false)
;environment=A="1",B="2" ; 這個是該子進程的環境變量,和別的子進程是不共享的
;serverurl=AUTO ; override serverurl computation (childutils)
;[eventlistener:theeventlistenername] ;這個東西其實和program的地位是同樣的,也是suopervisor啓動的子進程,不過它乾的活是訂閱supervisord發送的event。他的名字就叫listener了。咱們能夠在listener裏面作一系列處理,好比報警....
;command=/bin/eventlistener ; 和上面的program同樣,表示listener的可執行文件的路徑
;process_name=%(program_name)s ; 這個也同樣,進程名,當下面的numprocs爲多個的時候,才須要。不然默認就OK了
;numprocs=1 ; 相同的listener啓動的個數
;events=EVENT ; event event事件的類型,也就是說,只有寫在這個地方的事件類型。纔會被髮送
;buffer_size=10 ; event隊列緩存大小 (default 10)
;directory=/tmp ; 進程執行前,會切換到這個目錄下執行 (def no cwd)
;umask=022 ; umask for process (default None)
;priority=-1 ; 啓動優先級 (default -1)
;autostart=true ; true supervisord啓動一塊兒啓動 (default: true)
;startsecs=1 ; 設置子進程啓動多少秒以後,此時狀態若是是running,則咱們認爲啓動成功了 (def. 1)
;startretries=3 ; 失敗最大嘗試次數 (default 3)
;autorestart=unexpected ; 和program同樣 (def: unexpected)
;exitcodes=0,2 ; 'expected' exit codes used with autorestart (default 0,2)
;stopsignal=QUIT ; signal used to kill process (default TERM)
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
;killasgroup=false ; SIGKILL the UNIX process group (def false)
;user=chrism ; setuid to this UNIX account to run the program
;redirect_stderr=false ; redirect_stderr=true is not allowed for eventlisteners
;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10)
;stdout_events_enabled=false ; emit events on stdout writes (default false)
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
;stderr_events_enabled=false ; emit events on stderr writes (default false)
;environment=A="1",B="2" ; process environment additions
;serverurl=AUTO ; override serverurl computation (childutils)
;[group:thegroupname] ; 這個東西就是給programs分組,劃分到組裏面的program。咱們就不用一個一個去操做了 咱們能夠對組名進行統一的操做。 注意:program被劃分到組裏面以後,就至關於原來的配置從supervisor的配置文件裏消失了supervisor只會對組進行管理,而再也不會對組裏面的單個program進行管理了
;programs=progname1,progname2 ; 組成員,用逗號分開
;priority=999 ; 優先級,相對於組和組之間 (default 999)
;[include] ; 跟Nginx虛擬主機一個樣
;files = relative/directory/*.ini
supervisor 命令
supervisorctl status supervisorctl stop tomcat supervisorctl start tomcat supervisorctl restart tomcat supervisorctl reread supervisorctl update
supervisor配置開機啓動 centos7
[root@dev system]# cd /usr/lib/systemd/system
[root@dev system]# cat supervisor.service
[Unit]
Description=supervisor
After=network.target
[Service]
Type=forking
ExecStart=/bin/supervisord -c /etc/supervisord.conf
ExecStop=/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/bin/supervisorctl $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
[root@dev system]# systemctl enable supervisor
[root@dev system]# systemctl is-enabled supervisor
enabled
實際配置文件:
[root@dev supervisord.d]# cat /etc/supervisord.conf
; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
; - Shell expansion ("~" or "$HOME") is not supported. Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".
; - Quotes around values are not supported, except in the case of
; the environment= options as shown below.
; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
; - Command will be truncated if it looks like a config file comment, e.g.
; "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
[unix_http_server]
file=/var/sockets/supervisor.sock ; the path to the socket file
;chmod=0700 ; socket file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; default is no username (open server)
;password=123 ; default is no password (open server)
;[inet_http_server] ; inet (TCP) server disabled by default
;port=127.0.0.1:9001 ; ip_address:port specifier, *:port for all iface
;username=user ; default is no username (open server)
;password=123 ; default is no password (open server)
[supervisord]
logfile=/tmp/supervisord.log ; main log file; default $CWD/supervisord.log
logfile_maxbytes=50MB ; max main logfile bytes b4 rotation; default 50MB
logfile_backups=10 ; # of main logfile backups; 0 means none, default 10
loglevel=info ; log level; default info; others: debug,warn,trace
pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=false ; start in foreground if true; default false
minfds=1024 ; min. avail startup file descriptors; default 1024
minprocs=200 ; min. avail process descriptors;default 200
;umask=022 ; process file creation umask; default 022
;user=chrism ; default is current user, required if root
;identifier=supervisor ; supervisord identifier, default is 'supervisor'
;directory=/tmp ; default is not to cd during start
;nocleanup=true ; don't clean up tempfiles at start; default false
;childlogdir=/tmp ; 'AUTO' child log dir, default $TEMP
;environment=KEY="value" ; key value pairs to add to environment
;strip_ansi=false ; strip ansi escape codes in logs; def. false
; The rpcinterface:supervisor 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:x] sections.
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
; The supervisorctl section configures how supervisorctl will connect to
; supervisord. configure it match the settings in either the unix_http_server
; or inet_http_server section.
[supervisorctl]
serverurl=unix:///var/sockets/supervisor.sock ; use a unix:// URL for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris ; should be same as in [*_http_server] if set
;password=123 ; should be same as in [*_http_server] if set
;prompt=mysupervisor ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history ; use readline history if available
; The sample program section below shows all possible program subsection values.
; Create one or more 'real' program: sections to be able to control them under
; supervisor.
;[program:theprogramname]
;command=/bin/cat ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1 ; number of processes copies to start (def 1)
;directory=/tmp ; directory to cwd to before exec (def no cwd)
;umask=022 ; umask for process (default None)
;priority=999 ; the relative start priority (default 999)
;autostart=true ; start at supervisord start (default: true)
;startsecs=1 ; # of secs prog must stay up to be running (def. 1)
;startretries=3 ; max # of serial start failures when starting (default 3)
;autorestart=unexpected ; when to restart if exited after running (def: unexpected)
;exitcodes=0,2 ; 'expected' exit codes used with autorestart (default 0,2)
;stopsignal=QUIT ; signal used to kill process (default TERM)
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
;killasgroup=false ; SIGKILL the UNIX process group (def false)
;user=chrism ; setuid to this UNIX account to run the program
;redirect_stderr=true ; redirect proc stderr to stdout (default false)
;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10)
;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
;stdout_events_enabled=false ; emit events on stdout writes (default false)
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
;stderr_events_enabled=false ; emit events on stderr writes (default false)
;environment=A="1",B="2" ; process environment additions (def no adds)
;serverurl=AUTO ; override serverurl computation (childutils)
; The sample eventlistener section below shows all possible eventlistener
; subsection values. Create one or more 'real' eventlistener: sections to be
; able to handle event notifications sent by supervisord.
;[eventlistener:theeventlistenername]
;command=/bin/eventlistener ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1 ; number of processes copies to start (def 1)
;events=EVENT ; event notif. types to subscribe to (req'd)
;buffer_size=10 ; event buffer queue size (default 10)
;directory=/tmp ; directory to cwd to before exec (def no cwd)
;umask=022 ; umask for process (default None)
;priority=-1 ; the relative start priority (default -1)
;autostart=true ; start at supervisord start (default: true)
;startsecs=1 ; # of secs prog must stay up to be running (def. 1)
;startretries=3 ; max # of serial start failures when starting (default 3)
;autorestart=unexpected ; autorestart if exited after running (def: unexpected)
;exitcodes=0,2 ; 'expected' exit codes used with autorestart (default 0,2)
;stopsignal=QUIT ; signal used to kill process (default TERM)
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
;killasgroup=false ; SIGKILL the UNIX process group (def false)
;user=chrism ; setuid to this UNIX account to run the program
;redirect_stderr=false ; redirect_stderr=true is not allowed for eventlisteners
;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10)
;stdout_events_enabled=false ; emit events on stdout writes (default false)
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
;stderr_events_enabled=false ; emit events on stderr writes (default false)
;environment=A="1",B="2" ; process environment additions
;serverurl=AUTO ; override serverurl computation (childutils)
; The sample group section below shows all possible group values. Create one
; or more 'real' group: sections to create "heterogeneous" process groups.
;[group:thegroupname]
;programs=progname1,progname2 ; each refers to 'x' in [program:x] definitions
;priority=999 ; the relative start priority (default 999)
; 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/supervisord.d/*.ini
[root@dev supervisord.d]# cat activities.ini
[program:activities]
command =/data/init_start/activities.sh run
autostart=true
startsecs=5
autorestart=true
startretries=3
user=nobody
redirect_stderr = true
stdout_logfile_maxbytes=20MB
stdout_logfile_backups=20
stdout_logfile=/data/logs/supervisor/supervisor_django.log
stderr_logfile=/data/logs/supervisor/supervisor_error_django.log
stopasgroup=true
killasgroup=true
stopsignal=QUIT
[include]
files = /etc/supervisord.d/activities.ini
[root@dev supervisord.d]# cat /data/init_start/activities.sh
#!/bin/bash
env LANG=en_US.UTF-8
env LANGUAGE=en_US:
env LC_CTYPE=en_US.UTF-8
cd /data/website/activities/source/
ToDay=$(date '+%Y%m%d')
source /data/website/activities/virtualenv/bin/activate & source /data/website/activities/source/conf/develop.ini
/data/website/activities/virtualenv/bin/uwsgi -M -C -s /tmp/activities_service.sock --listen 10000 --wsgi-file /data/website/activities/source/base/wsgi.py --logto /data/logs/uwsgi/activities/access_${ToDay}.log --enable-threads --uid nobody --gid nobody
[root@dev system]# supervisorctl status
activities RUNNING pid 10200, uptime 4:17:43
[root@dev system]# supervisorctl stop activities
activities: stopped
[root@dev system]# supervisorctl status
activities STOPPED Jan 25 02:38 PM
[root@dev system]# supervisorctl start activities
activities: started
[root@dev system]# supervisorctl statusactivities RUNNING pid 11761, uptime 0:00:08