Configuration

ghz-web can be configured using environment variables or a configuration file.

Environment Variables

  • GHZ_SERVER_PORT - The port for the http server. Default is 80.
  • GHZ_DATABASE_TYPE - The SQL database dialect / type. Default is sqlite3.
  • GHZ_DATABASE_CONNECTION - The SQL database connection string. Default is data/ghz.db.
  • GHZ_LOG_LEVEL - The log level. One of debug, info, warn, or error. Default is info.
  • GHZ_LOG_PATH - By default the logs go to stdout. This option can be used to set the log path for a log file.

Configuration File

A cofiguration file can be specified using -config option. Configuration file can be in YAML, TOML or JSON format.

YAML

  1. ---
  2. server:
  3. port: 3000 # the port for the http server
  4. database: # the database options
  5. type: sqlite3
  6. connection: data/ghz.db
  7. log:
  8. level: info
  9. path: /tmp/ghz.log # the path to log file, otherwize stdout is used

TOML

  1. [server]
  2. port = 80 # the port for the http server
  3. [database] # the database options
  4. type = "sqlite3"
  5. connection = "data/ghz.db"
  6. [log]
  7. level = "info" # log level
  8. path = "/tmp/ghz.log" # the path to log file, otherwize stdout is used

JSON

  1. {
  2. "server": {
  3. "port": 80
  4. },
  5. "database": {
  6. "type": "sqlite3",
  7. "connection": "data/ghz.db"
  8. },
  9. "log": {
  10. "level": "info",
  11. "path": "/tmp/ghz.log"
  12. }
  13. }

Database

DialectConnection
sqlite3path/to/database.db
mysqldbuser:dbpassword@/ghz
postgreshost=dbhost user=dbuser dbname=ghz sslmode=disable password=dbpassword

When using postgres without SSL then sslmode=disable must be added to the connection string. When using mysql with host then tcp(host) must be added to the connection string like that dbuser:dbpassword@tcp(dbhost)/ghz.