我刚刚启动并运行resque-schedule,它可以正常运行一个计划任务。然而,当我在相同的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计划更改为不重叠,它们运行正常。感谢您的任何帮助。 OSx 10.6.6,Ruby 1.9.2p136。
请注意,这两个类的perform方法现在只需要调试put。
答案 0 :(得分:5)
好吧,可能是糟糕的表单回答我自己的问题,道歉......我发现这个SO thread并且线索是添加:thread_safe = true当我load_resque:
Resque.redis = Redis.new(:host => config['host'], :port => config['port'], :thread_safe => true)
注意:这是使用redis 2.1.1并且我认为我已经读过thread_safe现在是默认值。但是,我找不到那篇文章......