demarches-normaliennes/app/controllers/ping_controller.rb

17 lines
510 B
Ruby
Raw Normal View History

2016-06-01 15:07:27 +02:00
class PingController < ApplicationController
def index
2016-07-06 10:06:28 +02:00
Rails.logger.silence do
2020-06-21 18:34:59 +02:00
status_code = if File.file?(Rails.root.join("maintenance"))
# See https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4.2-http-check%20disable-on-404
:not_found
elsif (ActiveRecord::Base.connection.execute('select 1 as test;').first['test'] == 1)
2020-06-21 18:34:59 +02:00
:ok
2016-07-06 10:06:28 +02:00
else
2020-06-21 18:34:59 +02:00
:internal_server_error
2016-07-06 10:06:28 +02:00
end
2020-06-21 18:34:59 +02:00
head status_code, content_type: "application/json"
2016-06-01 15:07:27 +02:00
end
end
end