Celery + Django:无法在 Windows 7 上启动 celerybeat
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8706674/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Celery + Django: Cannot start celerybeat on Windows 7
提问by driftcatcher
Odd issues over here. I've been developing a Django application and I am now trying to implement Celery. I need both normal tasks and periodic tasks to be queued. I can start up celeryd just fine, and execute tasks with it (I start it with the command python manage.py celeryd start --settings=settings --loglevel=INFO
).
奇怪的问题在这里。我一直在开发 Django 应用程序,现在正在尝试实现 Celery。我需要将普通任务和周期性任务都排队。我可以很好地启动 celeryd,并用它执行任务(我用命令启动它python manage.py celeryd start --settings=settings --loglevel=INFO
)。
On Windows you can't do -beat
/-b
to enable beat mode; you need to start celerybeat as a separate service (this is stated in the FAQ section of the Celery docs). If I type this into the command line -- python manage.py celerybeat -s djcelery.schedulers.DatabaseScheduler --settings=settings --loglevel=INFO
-- I get an error like this:
在 Windows 上,您不能执行-beat
/-b
来启用节拍模式;您需要将 celerybeat 作为单独的服务启动(这在 Celery 文档的常见问题部分中有所说明)。如果我在命令行中输入这个 -- python manage.py celerybeat -s djcelery.schedulers.DatabaseScheduler --settings=settings --loglevel=INFO
-- 我会收到这样的错误:
[2012-01-02 19:06:52,009: WARNING/MainProcess] ERROR: Pidfile (celerybeat.pid) a
lready exists.
Seems we're already running? (PID: 2364)
[2012-01-02 19:06:52,012: INFO/MainProcess] process shutting down
and celerybeat never actually starts. So I can't execute any periodic tasks ... Any ideas? I only found one other pagewhere somebody highlighted a similar error, but no solution was offered.
和 celerybeat 从未真正启动。所以我不能执行任何定期任务......有什么想法吗?我只找到了另一个页面,其中有人强调了类似的错误,但没有提供解决方案。
If there's any further information needed, please let me know. I'm baffled because I can't find any information on this subject, and I've been trying solve this problem all day today ... Thank you.
如果需要任何进一步的信息,请告诉我。我很困惑,因为我找不到关于这个主题的任何信息,我今天一整天都在努力解决这个问题......谢谢。
回答by tkone
Search your file system for that pid file and delete it. On unix machines that usually means the program was not shut down correctly. You should check to see if its running in the task manager already, if so kill it, and delete that file
在您的文件系统中搜索该 pid 文件并将其删除。在 unix 机器上,这通常意味着程序没有正确关闭。您应该检查它是否已经在任务管理器中运行,如果是,则将其杀死,然后删除该文件
Then try again.
然后再试一次。
If there is no pid file present, that probably means there's an issue with the software as it was ported from unix perhaps?
如果不存在 pid 文件,那可能意味着软件存在问题,因为它可能是从 unix 移植的?
回答by javed
In my case of django project on Windows this file was already existing in root of the Django project. I deleted that file and the process ran without any error.
在我在 Windows 上的 django 项目中,这个文件已经存在于 Django 项目的根目录中。我删除了那个文件,这个过程没有任何错误地运行。
The "celerybeat.pid" was already existing because I ran celery beat from another PC and pushed the git repo to the cloud. When I pulled the repo on my working PC and ran the process, it gave me error referring to the file "celerybeat.pid" created earlier by another PC. Deleting the "celerybeat.pid" made it work.
“celerybeat.pid”已经存在,因为我从另一台 PC 运行 celery beat 并将 git repo 推送到云端。当我在我的工作 PC 上拉出 repo 并运行该进程时,它给了我错误,引用了另一台 PC 之前创建的文件“celerybeat.pid”。删除“celerybeat.pid”使其工作。