circus 進程以及socket 管理工具&&docker運行

circus 是由mozilla 團隊開發基於python 以及zeromq 的進程以及socket 管理的工具,相似supervisord
可是比supervisord 更靈活方便python

來自官方的使用比較

  • supervisord的

     

  • 來自circus 的

 

 

docker 集成shiyong

搜索docker hub 對於circus 的鏡像並非不少,並且文檔也不是很清晰,因此本身使用
pip 包安裝的方式作了了一個簡單的,方便測試,目前有一個bug,還在肯定緣由git

  • 項目結構
 
├── 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: 測試鏡像使用的(基於上邊構建的鏡像)github

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 配置,使用自帶的demoweb

[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 鏡像的entrypointdocker

#!/bin/sh
circusd /app/circus.ini

docker-compose.yaml 使用docker-compose 構建鏡像以及運行demosession

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 配置的集成是有問題的,異常信息以下,還在解決中app

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/circuswebapp

相關文章
相關標籤/搜索