2017-10-05 36 views
-1

錯誤: 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

回答

0

迫使你的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