项目参考官网资料,比较简单的add task
具体代码参考https://github.com/rongfengliang/celery-docker-demo
项目结构
├── README.md
├── client.py
├── docker-compose.yml
├── dockerfile
├── dockerfile-client
├── start.py
代码说明
broker 使用的是redis
clinet.py task 调用的
start.py task 定义
dockerfile worker 启动dockerfile 定义
dockerfile-client client 调用task dockerfile
运行
docker-compose build
docker-compose up -d
docker-compose logs -f worker // task log
docker-compose logs client // client call api
参考结果
worker:
2018-06-22 07:05:13,989: WARNING/MainProcess] celery@db7ce541ad07 ready.
worker_1 | [2018-06-22 07:05:14,107: INFO/MainProcess] Received task: start.add[d56e453c-5516-45da-9385-b5a659b818bf]
worker_1 | [2018-06-22 07:05:14,109: INFO/MainProcess] Task start.add[d56e453c-5516-45da-9385-b5a659b818bf] succeeded in 0.0006353879998641787s: 1001
client:
Attaching to first_client_1
client_1 | d56e453c-5516-45da-9385-b5a659b818bf
参考资料
http://docs.celeryproject.org/en/latest/userguide/application.html
https://github.com/rongfengliang/celery-docker-demo