【问题标题】:resque-scheduler and overlapping cronsresque-scheduler 和重叠的 crons
【发布时间】:2011-03-16 21:40:57
【问题描述】:

我刚刚启动并运行 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 方法现在都只有用于调试的 puts。

【问题讨论】:

    标签: ruby-on-rails-3 resque


    【解决方案1】:

    好的,回答我自己的问题可能是错误的形式,抱歉...我找到了这个SO thread,线索是在我加载时添加:thread_safe = true:

    Resque.redis = Redis.new(:host => config['host'], :port => config['port'], :thread_safe => true)
    

    注意:这是使用 redis 2.1.1 的,我认为我已经阅读 thread_safe 现在是默认设置。但是,我没有找到那篇文章...

    【讨论】:

    • 如果你找到了答案,回答你自己的问题是好的。这样,任何正在寻找同一问题的解决方案的人都能找到答案,而不仅仅是一个未回答的问题。
    猜你喜欢
    • 2012-11-07
    • 2011-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-29
    • 2013-12-05
    • 2015-09-17
    • 1970-01-01
    相关资源
    最近更新 更多