Check for necessary ENV variables in healthcheck

This commit is contained in:
Christoph Haas 2021-03-21 22:25:28 +01:00
parent 33240846b2
commit 31b19f3a2c

View file

@ -3,7 +3,7 @@
Healthcheck.configure do |config|
config.success = 200
config.error = 503
config.verbose = false
config.verbose = true
config.route = '/healthcheck'
config.method = :get
@ -14,8 +14,15 @@ Healthcheck.configure do |config|
# }
# -- Checks --
# config.add_check :database, -> { ActiveRecord::Base.connection.execute('select 1') }
# config.add_check :migrations, -> { ActiveRecord::Migration.check_pending! }
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