5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/gran_pulse/application_controller.rb', line 5
def index
result = []
GranPulse.checks.each do |check|
case check
when 'database'
result << GranPulse::Database.new.perform
when 'cache'
result << GranPulse::Cache.new.perform
when 'url'
GranPulse.url_checks.each do |url_check|
result << GranPulse::Url.new.perform(url_check)
end
end
end
errors = result.select{ |r| r.healthy == false }
if errors.empty?
respond_to do |format|
format.html { render :text => GranPulse.healthy, :content_type => 'text/plain' }
format.json { render :json => { :healthy => true, :checks => result }}
end
else
respond_to do |format|
format.html { render :text => errors, :content_type => 'text/plain' }
format.json { render :json => { :healthy => false, :checks => result }}
end
end
end
|