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 thehttp.port
configuration option, you can set theBHS_HTTP_PORT
environment variable.Configuration file - the configuration file is resolved next. The default configuration file is
config.yaml
in the working directory. You can also specify custom configuration file path using the-C
flag 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.go
file in theconfig
package. Default configuration fromdefaults.go
is the same as the configuration fromconfig.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
http
section contains theauth_token
which is used for admin api authentication. This key is used to authenticate the admin api calls.The
db
section contains theengine
section which can be set tosqlite
orpostgresql
. Thesqlite
is the default option. You can also define details about your database in this section.The
logging
section contains options which are used for logging. You can set thelevel
option todebug
,info
,warn
orerror
. Theformat
option can be set toconsole
orjson
. Theinstance_name
option is shown as a parameter in logs.The
metrics
section contains theenabled
option which is used to enable Prometheus metrics.
Last updated
Was this helpful?