我刚刚重新启动并运行了一个时间表任务,它工作得很好。然而,当我在相同的cron时间表上添加第二个时,它似乎是在自我践踏。下面是我的resque_schedule.yml的样子:
email_subscription_notification:
cron: * * * * *
class: SubscriptionProcessor
args: test
description: Email Notifications
email_polling:
cron: * * * * *
class: EmailPollingProcessor
args: test
description: Email Polling当我通过rake resque:scheduler运行时,我会得到周期性的错误:
2011-03-15 17:43:00 Failed to enqueue EmailPollingProcessor:
Got '0' as initial reply byte. If you're running in a multi-threaded environment, make sure you pass the :thread_safe option when initializing the connection. If you're in a forking environment, such as Unicorn, you need to connect to Redis after forking. 如果我改变时间表,只有一个或另一个,他们打得很好。如果我将cron调度更改为不重叠,它们运行得很好。谢谢你的帮助。Ruby10.6.6,OSx 1.9.2p136。
请注意,两个类的perform方法现在都只有puts用于调试。
发布于 2011-03-16 21:40:57
好吧,可能回答我自己的问题不太合适,抱歉……我找到了这个SO thread,提示是在我load_resque时添加:thread_safe = true:
Resque.redis = Redis.new(:host => config['host'], :port => config['port'], :thread_safe => true)注意:这是redis 2.1.1的版本,我想我已经读到thread_safe是默认的了。但是,我找不到那篇文章。
https://stackoverflow.com/questions/5319846
复制相似问题