demarches-normaliennes/app/controllers/ping_controller.rb
simon lehericey 00871cfe13 Fix ping controller in dev
For an unknown reason, ActiveRecord::Base.connected? does not work anymore in dev. It returns false negative.

This simple workaround can timeout. The caller has to monitor the response time.
2022-01-05 11:44:32 +01:00

16 lines
510 B
Ruby

class PingController < ApplicationController
def index
Rails.logger.silence do
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)
:ok
else
:internal_server_error
end
head status_code, content_type: "application/json"
end
end
end