Class: Healthcheck::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/healthcheck/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_initializer_fileObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/healthcheck/install_generator.rb', line 8

def create_initializer_file
  create_file(
    'config/initializers/healthcheck.rb',
    <<~HEALTHCHECK_INITIALIZER_TEXT
      # frozen_string_literal: true

      Healthcheck.configure do |config|
        config.success = 200
        config.error = 503
        config.verbose = false
        config.route = '/healthcheck'
        config.method = :get

        # -- 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') }
      end
    HEALTHCHECK_INITIALIZER_TEXT
  )
  route 'Healthcheck.routes(self)'
end