錯誤: 魯弗斯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
有人幫助請。這很迫切 –
你的Heroku系統上的rufus-scheduler版本是什麼?那裏的Ruby版本是什麼?用這些信息更新你的問題。 – jmettraux
請在您的Heroku系統上註明「et-orbi」gem的版本。 – jmettraux