Configuration (YAML, environment, flags)
Every server option has three spellings, and they mean the same thing:
| Spelling | Example |
|---|---|
| A flag | --read-only (a boolean flag alone means true), --port 31337, --port=31337 |
| An environment variable | HARDCHARGER_READ_ONLY=true (HARDCHARGER_ and the name in capitals) |
| A key in a YAML file | read_only: true (the flag without --, with _ for -) |
A flag wins over an environment variable, which wins over the file, which wins over the
default. The file is --config FILE or HARDCHARGER_CONFIG. An unknown flag or YAML key is an
error, and the server doesn’t start: a typo never goes unnoticed. The
server configuration reference lists every option with all three
spellings and its default.
A YAML file
Section titled “A YAML file”database: analytics.duckdbport: 31337health_port: 31338log_level: infoprint_queries: truememory_limit: 4GBsession_idle_timeout: 1800init_sql_commands_file: init.sqlcors_origins: # lists are YAML sequences, or one comma-separated string - https://app.example.com - https://admin.example.cominit_sql_commands_file runs once at startup, after init_sql_commands; any failure stops the
server. Use it to attach catalogs, create secrets and set DuckDB options:
SET threads = 4;CREATE TABLE IF NOT EXISTS trips AS SELECT * FROM (VALUES (1, 'Boston', 12.5), (2, 'Denver', 30.0)) t(id, city, miles);Start the server with the file, and the password from the environment:
HARDCHARGER_ADMIN_PASSWORD='change-me' hardcharger-server --config hardcharger.yamlSee what the server is running with
Section titled “See what the server is running with”hardcharger_settings() shows the settings you can read in SQL, with their current values:
$ export HARDCHARGER_PASSWORD='change-me'$ hardcharger --host localhost --tls=false --username hardcharger --csv --command \ "SELECT name, value FROM hardcharger_settings() WHERE name IN ('hardcharger.memory_limit', 'hardcharger.session_idle_timeout') ORDER BY name"name,valuehardcharger.memory_limit,4GBhardcharger.session_idle_timeout,1800$ hardcharger --host localhost --tls=false --username hardcharger --csv --command "SELECT count(*) AS trips FROM trips"trips2At startup, the server also logs where each option it was given came from.
Override one value
Section titled “Override one value”Flags and environment variables override the file, so one YAML file can serve several environments:
HARDCHARGER_ADMIN_PASSWORD='change-me' HARDCHARGER_MEMORY_LIMIT=2GB hardcharger-server --config hardcharger.yaml$ HARDCHARGER_PASSWORD='change-me' hardcharger --host localhost --tls=false --username hardcharger --csv --command \ "SELECT value FROM hardcharger_settings() WHERE name = 'hardcharger.memory_limit'"value2GBSecrets
Section titled “Secrets”HARDCHARGER_ADMIN_PASSWORDis required; the server doesn’t start without it.HARDCHARGER_SECRET_KEYsigns access tokens. Without it, each start picks a random key, and tokens die with the process. Set it, the same on every replica, for tokens that survive restarts.- In Kubernetes, put both in a Secret and reference it from the environment (guide).
Settings you can change while running
Section titled “Settings you can change while running”Some options are also SQL settings, which an administrator can change without a restart:
SET GLOBAL hardcharger.max_concurrent_statements = 8; -- every session, nowSET SESSION hardcharger.query_timeout = 60; -- this session onlyRESET SESSION hardcharger.query_timeout;The SQL settings reference says which settings take which scope. Everything else is fixed at startup.