本人 Ruby 新手一枚~ 刚刚开始自学 最近想给网站写一个 health check,具体代码如下
class HealthCheckController < ApplicationController
def dbping
begin
result = ActiveRecord::Base.connection.select_value("select 'alive' from dual")
render :text => "#{result}\n"
rescue => ex
logger.error ex.backtrace.join("\n")
raise ActiveRecord::ConnectionNotEstablished
end
end
#run a simple query to check the database
def deep_health
begin
result = ActiveRecord::Base.connection.select_value("XXXXXXXXXXXXXXX")
render :text => "#{result}\n"
rescue => exception
#log the error
logger.error exception.backtrace.join("\n")
end
end
end
实际检测网页中,dbping 是好用的,但是/deep_health 则出现了 template is missing 的情况。真心求助各位大大