Configuration

cataract.toml, and the config consts a built binary keeps.

Updated 2 min read

cataract.toml is read as a flat key/value subset of TOML: [section] headers, key = value, # comments, quoted or bare scalars. Nested tables and arrays are rejected rather than half-supported, and an unknown key is a build warning rather than a silent no-op.

[project]
name = "cataract-wiki"
version = "1.0.0"

[paths]
runtime = "../cataract/src/runtime"

[server]
host = "0.0.0.0"
port = 8443
max_concurrency = 512
max_body_bytes = 1048576
keep_alive_ms = 5000
header_timeout_ms = 10000
request_timeout_ms = 20000
log_level = "info"

[build]
optimize = true
chpl_flags = ""

[security]
csp = "default-src 'self'; object-src 'none'; frame-ancestors 'none'"
hsts_seconds = 31536000
allowed_origins = "https://cataract.wiki"

Timeouts

header_timeout_ms bounds a single read. request_timeout_ms bounds the whole request and is armed when the first byte arrives โ€” which is the one a dripping client cannot restart by sending another byte.

Paths

app, routes, layouts, islands, lib, public, out and dist all default to the standard tree and can be moved. runtime must point at the framework's src/runtime and is resolved relative to the directory holding cataract.toml. If it is unset or missing, CATARACT_RUNTIME is used; a configured path that exists always wins.

Runtime overrides

Every server setting becomes a Chapel config const, so a compiled binary is reconfigurable without a rebuild:

./dist/cataract-wiki --port=8080 --host=127.0.0.1 --logLevel=debug
./dist/cataract-wiki --maxConcurrency=2048 --requestTimeoutMillis=5000
./dist/cataract-wiki --staticRoot=/srv/wiki/public
FlagFrom
--host --port --logLevelThe matching server keys
--maxConcurrency --maxBodyBytesmax_concurrency, max_body_bytes
--keepAliveMillis --headerTimeoutMillis --requestTimeoutMillisThe matching timeouts
--hstsSeconds --allowedOriginsThe matching security keys
--staticRootThe built asset directory
--devModeDisables the static file cache
--serverTokenThe Server response header

--staticRoot matters in deployment: the built-in value is the path the asset directory had at build time, so a binary moved to another machine needs it set, or needs to be run from the build root.

Application config consts

Your own modules can declare config const too, and they get the same treatment. This wiki declares two:

config const contentRoot: string = "content";
config const siteEnvironment: string = "";
./dist/cataract-wiki --contentRoot=/srv/wiki/content --siteEnvironment=development