首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >resque-scheduler和重叠crons

resque-scheduler和重叠crons
EN

Stack Overflow用户
提问于 2011-03-16 08:55:59
回答 1查看 1.1K关注 0票数 2

我刚刚重新启动并运行了一个时间表任务,它工作得很好。然而,当我在相同的cron时间表上添加第二个时,它似乎是在自我践踏。下面是我的resque_schedule.yml的样子:

代码语言:javascript
复制
email_subscription_notification:
  cron: * * * * *
  class: SubscriptionProcessor
  args: test
  description: Email Notifications
email_polling:
  cron: * * * * *
  class: EmailPollingProcessor
  args: test
  description: Email Polling

当我通过rake resque:scheduler运行时,我会得到周期性的错误:

代码语言:javascript
复制
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用于调试。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-03-16 21:40:57

好吧,可能回答我自己的问题不太合适,抱歉……我找到了这个SO thread,提示是在我load_resque时添加:thread_safe = true:

代码语言:javascript
复制
Resque.redis = Redis.new(:host => config['host'], :port => config['port'], :thread_safe => true)

注意:这是redis 2.1.1的版本,我想我已经读到thread_safe是默认的了。但是,我找不到那篇文章。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5319846

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档