Configuration
This guide will help you to know the most important configuration options for the Block Headers Service.
Order of resolving configuration
The configuration is resolved in the following priority
- Environment variables - the environment variables are prefixed with - BHS_and are in uppercase. They have the highest priority when resolving the configuration. You can override any of the configuration options by setting the environment variable with the same name as the configuration option. For example, to override the- http.portconfiguration option, you can set the- BHS_HTTP_PORTenvironment variable.
- Configuration file - the configuration file is resolved next. The default configuration file is - config.yamlin the working directory. You can also specify custom configuration file path using the- -Cflag in the command line.
- If you don't specify the configuration file and environment variables, the default configuration will be used - it's resolved in - defaults.gofile in the- configpackage. Default configuration from- defaults.gois the same as the configuration from- config.example.yaml.
Configuration File
There is an example of the configuration in a file called config.example.yaml in the root of the project. You can copy this file to config.yaml and modify it to your needs.
The most important configuration options are:
# Application Configuration Example
# Database Configuration
db:
  # Database engine [sqlite|postgres] (default: sqlite)
  engine: sqlite
  # Path to the database schema
  schema_path: "./database/migrations"
  # Whether prepared DB is enabled
  prepared_db: false
  # Path to prepared database file
  prepared_db_file_path: "./data/blockheaders.csv.gz"
  #sqlite engine configuration
  sqlite:
    file_path: "./data/blockheaders.db"
  #postgres engine configuration, required when engine=postgres
  postgres:
    host: "localhost"
    port: 5432
    user: "user"
    password: "password"
    db_name: "bhs"
    ssl_mode: "disable" #[disable|enable]
# HTTP Configuration
http:
  # HTTP server port
  port: 8080
  # Authentication token
  auth_token: "mQZQ6WmxURxWz5ch"
  # Flag for enabling additional endpoits for profiling with use of pprof
  debug_profiling: true
# Logging Configuration
logging:
  # Logging level
  level: debug
  # Logging format: console/json
  format: console
  # Instance name shown as parameter in logs
  instance_name: block-header-service
  # Flag for enabling origin parameter in logs
  origin: false
# Prometheus metrics configuration
metrics:
  enabled: false
Going through highlighted options:
- The - httpsection contains the- auth_tokenwhich is used for admin api authentication. This key is used to authenticate the admin api calls.
- The - dbsection contains the- enginesection which can be set to- sqliteor- postgresql. The- sqliteis the default option. You can also define details about your database in this section.
- The - loggingsection contains options which are used for logging. You can set the- leveloption to- debug,- info,- warnor- error. The- formatoption can be set to- consoleor- json. The- instance_nameoption is shown as a parameter in logs.
- The - metricssection contains the- enabledoption which is used to enable Prometheus metrics.
Last updated
