28 lines
914 B
Ruby
28 lines
914 B
Ruby
# frozen_string_literal: true
|
|
|
|
Healthcheck.configure do |config|
|
|
config.success = 200
|
|
config.error = 503
|
|
config.verbose = true
|
|
config.route = '/healthcheck'
|
|
config.method = :get
|
|
|
|
# -- Custom Response --
|
|
# config.custom = lambda { |controller, checker|
|
|
# controller.render json: my_custom_response unless checker.errored?
|
|
# ...
|
|
# }
|
|
|
|
# -- Checks --
|
|
config.add_check :database, -> { ActiveRecord::Base.connection.execute('select 1') }
|
|
config.add_check :migrations, -> { ActiveRecord::Migration.check_pending! }
|
|
# config.add_check :cache, -> { Rails.cache.read('some_key') }
|
|
# config.add_check :environments, -> { Dotenv.require_keys('ENV_NAME', 'ANOTHER_ENV') }
|
|
config.add_check :env, -> {
|
|
keys = %W(SALSA_OAUTH_KEY SALSA_OAUTH_SECRET)
|
|
keys.each do |key|
|
|
puts "checking key"
|
|
raise "Env variable #{key} not set" unless ENV.key?(key)
|
|
end
|
|
}
|
|
end
|