具有每天运行的 rufus-scheduler 作业的 JRuby/Rails 应用程序。但是,当应用程序运行到 Java 堆空间 (Tomcat) 中时,作业将停止静默运行。
这显然只发生在线程安全模式下。
抽象的config/initializer/update_scheduler.rb
scheduler = Rufus::Scheduler.start_new
#Runs everyday at 7:30 AM - expected after all ETL/MV refreshes are executed
scheduler.cron("30 7 * * *", :tags => 'auto_update') do
begin
# do stuff
Rails.logger.info "log info and duration"
rescue Exception => s_e
Rails.logger.error "Scheduler Failed"
end
Rails.logger.flush
end
class << scheduler
def lwarn (&block)
Rails.logger.error("Scheduler Error: " + block.call)
end
end
MyApp::Application.config.scheduler = scheduler