2017-06-29 61 views
0

開始sidekiq與命令錯誤 「未定義的方法`to_datetime'」 在sidekiq

bundle exec sidekiq -e production -P /path/to/pid/file/tmp/pids/sidekiq.pid -L /path/to/log/file/shared/log/sidekiq.log --daemon 

在日誌錯誤

2017-06-29T06:59:44.776Z 16181 TID-1jr7pg ERROR: CRON JOB: undefined method `to_datetime' for #<EtOrbi::EoTime:0x0000000a933848> 
2017-06-29T06:59:44.776Z 16181 TID-1jr7pg ERROR: CRON JOB: /home/user/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/core_ext/date_time/calculations.rb:141:in `<=>' 

錯誤而執行該方法/home/user/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/core_ext/date_time/calculations.rb:141:in <=>

def <=> (other) 
    super other.kind_of?(Infinity) ? other : other.to_datetime 
end 

這個問題能做些什麼?


UPD:版本更新導軌3.2.22.5並有一個新的錯誤

ERROR: CRON JOB: comparison of Time with EtOrbi::EoTime failed 
ERROR: CRON JOB: /home/user/.rvm/gems/[email protected]/gems/sidekiq-cron-0.3.1/lib/sidekiq/cron/job.rb:434:in `<' 

在這個地方

def not_enqueued_after?(time) 
    @last_enqueue_time.nil? || @last_enqueue_time < last_time(time) 
end 

回答

1

您的問題從sidekiq產生而是來自Rails的3.2。 13。 #<=>不處理undefined method to_datetime。它在Rails的未來版本中得到修復。例如,在Rails的3.2.22.5:

def <=>(other) 
    if other.kind_of?(Infinity) 
    super 
    elsif other.respond_to? :to_datetime 
    super other.to_datetime 
    else 
    nil 
    end 
end 

因此,要解決您的問題最簡單的方法是更新你的Rails版本。如果它不是選項粘貼您的代碼或重寫#<=>

+0

感謝,但現在'與EtOrbi :: EoTime時間比較failed' – dmitriy

1

to_datetime是一種來自Rails'activesupport library的方法,您的sidekiq工作人員不會使用它。

嘗試加入require 'active_support/core_ext'您sidekiq初始化配置config/initializers/sidekiq.rb並重新啓動sidekiq

+0

感謝,但我有新的錯誤。我更新了問題。 – dmitriy

+0

好像比較失敗,因爲你試圖比較來自gem'EtOrbi :: EoTime'的時間對象與紅寶石的標準'DateTime'對象 – sa77

+0

說實話,我不能做調試:) – dmitriy