如何使用Django运行自己的守护进程? [英] How to run own daemon processes with Django?
问题描述
在我的Django项目中,我不得不在后台多次做一些处理。
这个处理需要访问Django的东西,所以我把它放入Django的命令,并运行它作为cronjob。
现在我意识到,我必须更频繁地做一些(cronjob有限制,最多每1分钟调用命令)。另一个问题是,我没有足够的控制,以保护一次运行相同的命令。它发生在一个处理超过一分钟。
我认为我应该像守护进程一样运行它们,但是我正在寻找纯粹的方式来使用Django。
你有面对这个问题或者知道任何干净的解决方案吗?
In my Django project I have to do repeatedly some processing in the background. This processing needs access to Django stuff, so I put it into Django's commands and run it as cronjob. Right now I realize, that I have to do some of them more frequently (cronjob has limitation to invoke command at most every 1 minute). Another problem is that I don't have enough control, to protect running the same command in one time. It's happen when one processing takes longer than one minute. I think that I should run them like daemons, but I am looking for pure way to do it with Django. Have you ever faced with this problem or know any clean solution for it?
推荐答案
我们做了很多背景使用Celery处理django http://celeryproject.org/ 。它需要一些努力来设置,有一个学习曲线,但一旦它的运行它只是真棒。
We do a lot of background processing for django using Celery http://celeryproject.org/. It requires some effort to set up and there is a bit of a learning curve, but once it's up and running it's just awesome.
这篇关于如何使用Django运行自己的守护进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!