docker容器内通过supervisor来守护进程

安装:

可通过easy install supervisor或pip install supervisor,当然还可以通过下载源码通过python setup.py install 来安装(注意:要在python2.x下进行安装)

还可以通过linxu下的包管理来安装,如yum install supervisor



使用:
.为要维护的进程创建.ini文件,并放到/etc/supervisor.d目录下
.启动supervisord服务
  /usr/bin/supervisord -c /etc/supervisor.conf

可通过supervisorctl status  查看supervisord当前管理的所有进程的状态


遇到的问题:
通过docker run -d 方式启动容器报“Unlinking stale socket /tmp/supervisor.sock”错误,而通过docker run -it 启动后手动执行  /usr/bin/supervisord -c /etc/supervisor.conf则没问题
解决:
将Dockerfile中的CMD  ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] 修改成ENTRYPOINT ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"] 重新生成镜像,用该镜像启动容器docker run -d即可,问题解决。



猜你喜欢

转载自blog.csdn.net/weiguang1017/article/details/77493142