##Supervisorpython
##Centos Supervisor安裝redis
###要求 python環境 由於是一個 Python 程序 [root@localhost wang]# python -V Python 2.7.5docker
yum install python-setuptools easy_install supervisor
###驗證: 成功安裝後能夠登錄pythoncentos
>>> import supervisor
查看是否能成功加載 ###Supervisor配置bash
echo_supervisord_conf > /etc/supervisord.conf
supervisor自帶有Web 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))微信
###啓動supervisor:ssh
supervisord -c /etc/supervisord.confui
[root@localhost wang]# ps -ef |grep supervisord root 24673 1 0 07:19 ? 00:00:00 /usr/bin/python /usr/bin/supervisordthis
supervisord 是後臺管理服務器, 用來依據配置文件的策略管理後臺守護進程; supervisorctl 用於管理員向後臺管理程序發送 啓動/重啓/中止 等指令
##docker Container同時啓動多服務
###建立Dockerfile:
# use this image to run multiple service # add service in supervisord.conf FROM centos:latest MAINTAINER edwardsbean@gmail.com RUN yum install -y supervisor RUN mkdir -p /var/run/sshd RUN mkdir -p /var/log/supervisor ADD supervisord.conf /etc/supervisord.conf # expose your port to host EXPOSE 22 80
建立supervisord.conf
[supervisord] nodaemon=true [program:sshd] command=/usr/sbin/sshd -D [program:redis] command=redis-server /etc/redis/redis.conf
###build鏡像
#!/bin/bash docker build -f /home/wang/scripts/docker/Dockerfile -t myredis .
若是有更多疑問 關注微信帳號