鲁弗斯scheduler.at不能在Heroku的日志分析在Heroku时间

问题描述:

错误: enter image description here鲁弗斯scheduler.at不能在Heroku的日志分析在Heroku时间

代码包含鲁弗斯调度:

def checkout_timer time, id, lpn 
    scheduler = Rufus::Scheduler.new 
    time_to_do = time + 1.minute 
    Rails.logger.info "time_to_do: #{time_to_do}, id: #{id}" 
    scheduler.at time_to_do do 
     Rails.logger.info "hello, it's #{Time.now}" 
     reservation = Reservation.find(id) 
     if reservation&&reservation.status == 'Reserved' 
     reservation.destroy 
     Car.where(:lpn => lpn).update_all(:status => "Available") 
     notification = Notification.new(:email => reservation.email, :message => 'You do not check out the car on time !') 
     notification.save 
     end 
    end 
    end 

代码调用调度:

if user && @reservation1 == [] && @reservation.save 
     return_timer @reservation.expect_return_time, @reservation.id, @reservation.lpn 
     @reservation.update_attribute(:expect_start_time, Time.now) 
     @car = Car.find_by_lpn(@reservation.lpn) 
     @car.update_attribute(:status, "Checkout") 
     format.html {redirect_to @car, notice: 'Rent successfully.'} 
     # format.json { render :show_reserve, status: :reserved, location: @reservation } 

@reservation .expect_return_time从

得到它的值
<p> 
     <%= f.label :expect_start_time,'Expect checkout time' %> 
     <%= f.datetime_select :expect_start_time %> 
    </p> 

它在我的本地机器上正确运行。我记得昨天在heroku上没有任何问题。然而,这个奇怪的问题今天发生在heroku上。

更新:

  • 的Ruby 2.3.4版
  • 鲁弗斯调度版本3.4.2
  • 有Et Orbi版本1.0.6
+0

有人帮助请。这很迫切 –

+0

你的Heroku系统上的rufus-scheduler版本是什么?那里的Ruby版本是什么?用这些信息更新你的问题。 – jmettraux

+0

请在您的Heroku系统上注明“et-orbi”gem的版本。 – jmettraux

迫使你的Heroku使用1.0.5版本的宝石“et-orbi”。

请注意,对checkout_timer的每次调用启动一个新的Rufus-Scheduler实例是浪费资源。它将rufus-scheduler实例暴露给垃圾收集,如果它发生在作业的指定时间之前,那么作业将不会触发。

更新2017年10月7日

宝石“等-orbi”,由鲁弗斯调度使用,在1.0.7版本包含此问题的修复程序。

+0

但是如果我使用Rufus :: Scheduler.singleton,例如,我有scheduler.in'30s'和scheduler.in'1minute',第二个会覆盖第一个吗? –

+0

不,它不会。 请自己尝试:https://gist.github。 COM/jmettraux/8cb63397fe55896933518f2c6e52af34 – jmettraux