2017-06-29 19 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

相关问题