resque-scheduler和重叠的crons

Mar*_*dig 2 resque ruby-on-rails-3

我刚刚启动并运行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
Run Code Online (Sandbox Code Playgroud)

当我通过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. 
Run Code Online (Sandbox Code Playgroud)

如果我将时间表更改为只有一个或另一个,他们会很好地发挥作用.如果我将cron计划更改为不重叠,它们运行正常.感谢您的任何帮助.OSx 10.6.6,Ruby 1.9.2p136.

请注意,这两个类的perform方法现在只需要调试.

Mar*_*dig 5

好吧,可能是糟糕的形式回答我自己的问题,道歉...我发现这个SO线程和线索是添加:thread_safe = true当我load_resque:

Resque.redis = Redis.new(:host => config['host'], :port => config['port'], :thread_safe => true)
Run Code Online (Sandbox Code Playgroud)

注意:这是使用redis 2.1.1而我认为我已经读过thread_safe现在是默认值.但是,我找不到那篇文章......

  • 如果你找到答案,回答你自己的问题是好的.这样,正在寻找同一问题解决方案的任何其他人都会找到答案,而不仅仅是一个未解决的问题. (3认同)