circus 进程以及socket 管理工具&&docker运行
circus 是由mozilla 团队开发基于python 以及zeromq 的进程以及socket 管理的工具,类似supervisord
但是比supervisord 更灵活方便
来自官方的使用比较
- supervisord的
- 来自circus 的
docker 集成shiyong
搜索docker hub 对于circus 的镜像并不是很多,而且文档也不是很清晰,所以自己使用
pip 包安装的方式做了了一个简单的,方便测试,目前有一个bug,还在确定原因
- 项目结构
├── Dockerfile
├── Dockerfile-Test
├── README.md
├── circus.ini
├── docker-compose.yaml
└── entrypoint.sh
- 代码说明
Dockerfile: circus docker 镜像文件(构建)
FROM python:slim-stretch
LABEL AUTHOR="dalongrong"
LABEL EMAIL="1141591465@qq.com"
RUN apt-get update && apt-get install -y --reinstall build-essential \
&& pip install circus circus-web chaussette \
&& apt-get remove -y --purge build-essential \
&& rm -rf /var/lib/apt/lists/*
Dockerfile-Test: 测试镜像使用的(基于上边构建的镜像)
FROM dalongrong/circus
WORKDIR /app
COPY circus.ini /app/
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
circus.ini: demo 运行circus 配置,使用自带的demo
[circus]
statsd = True
httpd = False
[watcher:webapp]
cmd = /usr/local/bin/chaussette --fd $(circus.sockets.web)
numprocesses = 5
use_sockets = True
[socket:web]
host = 0.0.0.0
port = 9999
entrypoint.sh: demo 镜像的entrypoint
#!/bin/sh
circusd /app/circus.ini
docker-compose.yaml 使用docker-compose 构建镜像以及运行demo
version: "3"
services:
circus:
build: ./
web:
build:
dockerfile: Dockerfile-Test
context: ./
ports:
- "9999:9999"
- "8080:8080"
构建&&运行
- 构建
为了加速以及方便构建使用了docker hub 的构建功能,只需要添加github 集成即可,构建好的
镜像名称dalongrong/circus
- 使用
docker-compose up -d web
- 访问效果
说明
当前对于circushttpd web 配置的集成是有问题的,异常信息如下,还在解决中
web_1 | SyntaxError: invalid syntax
web_1 | Traceback (most recent call last):
web_1 | File "<string>", line 1, in <module>
web_1 | File "/usr/local/lib/python3.7/site-packages/circusweb/circushttpd.py", line 25, in <module>
web_1 | import tornadio2
web_1 | File "/usr/local/lib/python3.7/site-packages/tornadio2/__init__.py", line 25, in <module>
web_1 | from tornadio2.router import TornadioRouter
web_1 | File "/usr/local/lib/python3.7/site-packages/tornadio2/router.py", line 27, in <module>
web_1 | from tornadio2 import persistent, polling, sessioncontainer, session, proto, preflight, stats
web_1 | File "/usr/local/lib/python3.7/site-packages/tornadio2/persistent.py", line 143
web_1 | except Exception, ex:
web_1 | ^
web_1 | SyntaxError: invalid syntax
参考资料
https://circus.readthedocs.io/en/latest/faq/
https://github.com/rongfengliang/circus-docker
https://cloud.docker.com/repository/docker/dalongrong/circus