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
|
2023-04-19 10:55:16 +02:00
|
|
|
status_code = if Rails.root.join("maintenance").file?
|
2020-06-21 18:34:59 +02:00
|
|
|
# See https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4.2-http-check%20disable-on-404
|
|
|
|
:not_found
|
2022-01-05 10:53:14 +01:00
|
|
|
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
|