2

resque-schedule を起動して実行しているところですが、1 つのスケジュール タスクで問題なく動作します。ただし、同じ cron スケジュールに 1 秒追加すると、それ自体が踏みにじられているように見えます。私の 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、ルビー 1.9.2p136。

両方のクラスの perform メソッドには、現在デバッグ用の put しかないことに注意してください。

4

1 に答える 1

5

わかりました、おそらく私自身の質問に答える悪いフォーム、お詫び...私はこのSOスレッドを見つけました、そして手がかりは私がload_resque:のときに:thread_safe =trueを追加することでした:

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

注:これはredis 2.1.1でのことで、thread_safeがデフォルトであると読んだと思いました。しかし、私はその記事を見つけていません...

于 2011-03-16T13:40:57.017 に答える