项目作者: dengshaochun

项目描述 :
django-celery example
高级语言: Python
项目地址: git://github.com/dengshaochun/djcelery-example.git
创建时间: 2018-05-04T04:20:20Z
项目社区:https://github.com/dengshaochun/djcelery-example

开源协议:

下载


djcelery-example

django-celery 使用方法demo(官方demo不完全),支持celery 调用ansible api。

feature

  • 支持django admin页面查看日志
  • 支持页面配置crotab任务
  • 支持celery 调用ansible api接口

Install

  1. # 安装并启动redis
  2. $ sudo yum intall redis supervisor -y && sudo service redis start
  3. # 下载项目
  4. $ git clone https://github.com/dengshaochun/djcelery-example.git && cd proj
  5. # 安装依赖包(需先安装pipenv)
  6. $ pipenv install . && pipenv install -r requirements.txt
  7. # 初始化数据库
  8. $ pipenv run python manage.py migrate
  9. # 创建super user
  10. $ pipenv run python manage.py createsuperuser
  11. # 启动superviosr
  12. $ supervisord -c djcelery.ini && supervisorctl -c djcelery.ini status
  13. # 启动django web(浏览器地址 http://localhost:9009)
  14. $ pipenv run python manage.py runserver 0.0.0.0:9009

Python shell 提交任务

  1. $ pipenv run python manage.py shell
  2. Python 2.7.5 (default, Aug 4 2017, 00:39:18)
  3. Type "copyright", "credits" or "license" for more information.
  4. IPython 5.6.0 -- An enhanced Interactive Python.
  5. ? -> Introduction and overview of IPython's features.
  6. %quickref -> Quick reference.
  7. help -> Python's own help system.
  8. object? -> Details about 'object', use 'object??' for extra details.
  9. In [1]: from demo.tasks import mul
  10. In [2]: p = mul.delay(5, 6)
  11. In [3]: p.status
  12. Out[3]: u'SUCCESS'
  13. In [4]: p.result
  14. Out[4]: 30
  15. In [5]: exit

Blog doc