resque-scheduler and overlapping crons
I'm just getting resque-schedule up and running and it works fine with one schedule task. However, when I 开发者_开发百科added a second on the same cron schedule it seems it is stomping on itself. Here's what my resque_schedule.yml looks like:
email_subscription_notification:
cron: * * * * *
class: SubscriptionProcessor
args: test
description: Email Notifications
email_polling:
cron: * * * * *
class: EmailPollingProcessor
args: test
description: Email Polling
When I run via rake resque:scheduler I will get periodic errors:
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.
If I change the schedule to just have one or the other, they play nicely. If I change the cron schedules to not overlap, they run fine. Thank you for any help. OSx 10.6.6, Ruby 1.9.2p136.
Note both classes' perform method just have puts for debugging right now.
Ok, probably bad form answering my own question, apologies... I found this SO thread and the clue was to add :thread_safe = true when I load_resque:
Resque.redis = Redis.new(:host => config['host'], :port => config['port'], :thread_safe => true)
Note: This was with redis 2.1.1 and I thought I had read thread_safe was the default now. But, I'm not finding that article...
精彩评论