docker之使用supervisor管理多個程序
阿新 • • 發佈:2019-01-09
docker題外話:
centos7安裝supervisor:
原始碼編譯安裝:
下載原始碼檔案:supervisor-3.3.1.tar.gz 下載地址:https://pypi.python.org/pypi/supervisor
1234567891011121314 | 安裝: [[email protected] src] # tar -zxf supervisor-3.3.1.tar.gz [[email protected] src] # cd supervisor-3.3.1/ [[email protected] supervisor-3.3.1] # python setup.py install 檢查是否安裝成功: 登陸python控制檯輸入 import supervisor 檢視是否能成功載入 [[email protected] supervisor-3.3.1] # python Python 2.7.5 (default, Sep 15 2016, 22:37:39) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2 Type "help" , "copyright" , "credits" or "license" for more information. >>> import supervisor >>> |
1234567891011121314151617181920 | 生成配置檔案: [[email protected] supervisor-3.3.1] # mkdir /etc/supervisor [[email protected] supervisor-3.3.1] # echo_supervisord_conf > /etc/supervisor/supervisord.conf [[email protected] supervisor-3.3.1] # grep -E -v '^;|^$' /etc/supervisor/supervisord.conf [unix_http_server] file = /tmp/supervisor .sock ; (the path to the socket file ) [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 ; (num of main logfile rotation backups;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) [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=unix: ///tmp/supervisor .sock ; use a unix: // URL for a unix socket |
123456789101112 | 啟動服務: [[email protected] tmp] # supervisord -c /etc/supervisor/supervisord.conf 關閉服務: [[email protected] tmp] # supervisorctl shutdown Shut down 檢視狀態: [[email protected] tmp] # supervisorctl status 啟動或停止某一個服務: supervisorctl stop|start program_name |