我正在用瓶子建造一些项目,我需要它定期运行某些预定的行动。
我决定选择rabbitmq + celery,因为它看起来像是最强大的&以编程方式管理预定作品的完整解决方案。
我安装了rabbitmq和芹菜,当我使用celeryd -B时,任务就可以了。 但是,当我使用celerybeat命令时,任务被“发送”(或者说输出,因为我运行celeryd和celerybeat并使用-l debug选项更加冗长),但是虽然它们经常被“发送”,但它们不会执行(为了测试目的,任务应该每隔60秒将当前时间戳附加到文件)。 无论如何,其他一切工作正常,因为在同一目录中的celeryd -B命令工作得很好,它以预期的间隔写入文件。
我错过了什么吗?
这是$ celerybeat -l debug:
的输出[2012-06-30 18:07:44,676: WARNING/MainProcess] celerybeat v2.5.5 is starting.
[2012-06-30 18:07:44,750: WARNING/MainProcess] __ - ... __ - _
Configuration ->
. broker -> amqp://guest@localhost:5672//
. loader -> celery.loaders.default.Loader
. scheduler -> celery.beat.PersistentScheduler
. db -> celerybeat-schedule
. logfile -> [stderr]@DEBUG
. maxinterval -> 5.00 minutes (300s)
[2012-06-30 18:07:44,751: DEBUG/MainProcess] Setting default socket timeout to 30
[2012-06-30 18:07:44,751: INFO/MainProcess] Celerybeat: Starting...
[2012-06-30 18:07:44,776: DEBUG/MainProcess] Current schedule:
<Entry: celery.backend_cleanup celery.backend_cleanup() {<crontab: 0 4 * (m/h/d)>}
<Entry: often tasks.output() {<freq: 1.00 minute>}
[2012-06-30 18:07:44,776: DEBUG/MainProcess] Celerybeat: Ticking with max interval->5.00 minutes
[2012-06-30 18:07:44,781: DEBUG/MainProcess] Start from server, version: 8.0, properties: {u'information': u'Licensed under the MPL. See http://www.rabbitmq.com/', u'product': u'RabbitMQ', u'copyright': u'Copyright (C) 2007-2012 VMware, Inc.', u'capabilities': {}, u'platform': u'Erlang/OTP', u'version': u'2.8.4'}, mechanisms: [u'PLAIN', u'AMQPLAIN'], locales: [u'en_US']
[2012-06-30 18:07:44,785: DEBUG/MainProcess] Open OK! known_hosts []
[2012-06-30 18:07:44,787: DEBUG/MainProcess] using channel_id: 1
[2012-06-30 18:07:44,789: DEBUG/MainProcess] Channel open
[2012-06-30 18:07:44,790: INFO/MainProcess] Scheduler: Sending due task tasks.output
[2012-06-30 18:07:44,794: DEBUG/MainProcess] Celerybeat: Synchronizing schedule...
[2012-06-30 18:07:44,838: DEBUG/MainProcess] tasks.output sent. id->53951ab0-022d-40a5-9f56-9a4a294294c7
[2012-06-30 18:07:44,838: DEBUG/MainProcess] Celerybeat: Waking up in 1.00 minute.
答案 0 :(得分:1)
Celerybeat本身就可以将时间和任务铲除到适当的队列上供其他人消费。
Ergo,启动一个celeryd进程,监听你想要处理的队列:
$ celeryd <queuename> -l DEBUG