Skip to content

Hot reload and dynamic config ​

BatleHub can reload its configuration at runtime without restarting the process — but not all of it. Every key falls in one of three tiers:

  • hot — every reader sees the new value once the reload is applied;
  • partial — every request sees it, while a component built once at startup (warming, release imports, the scan worker) keeps the old value until a restart. A rotated upstream credential is the case that matters: installs use the new one at once, warming keeps calling with the old one;
  • restart — nothing reads it again before a restart.

A key no row below names is restart: a section added to the configuration later is restart-only until someone shows a reader for it, because a needless restart costs seconds and a reload that silently does nothing costs an incident. The most specific row wins, so registries[npm].cache.metadata_ttl_secs is partial while registries[npm].cache.idle_days is restart.

KeyTierRead by
grantshotthe instance-tier grants
ip_blocking.trusted_proxieshotthe proxy-trust policy, as the deprecated fallback of server.trusted_proxies
limits.packages_per_pagehotlisting pagination
limits.versions_per_pagehotlisting pagination
registries[*].auto_wirehotthe mise wire table and overlay (RFC 0045), rebuilt with the routing table
registries[*].cache.serve_stalehotthe registry's metadata policy
registries[*].grantshotthe registry's grant hierarchy
registries[*].hostshotthe host → registry routing table
registries[*].path_routinghotthe host → registry routing table
registries[*].rbachotthe registry's grant hierarchy
registries[*].ruleshotthe registry's rule chain
scanners.*.escalationhoteach registry's security policy
search.readmeshotthe prose-search switch
server.signed_urlshotthe download URL signer
server.trusted_proxieshotthe proxy-trust policy, swapped together with the host routing table
stats.dashboard_urlhotthe Dashboard's monitoring link
stats.registry_dashboard_urlhotthe registry views' monitoring links
subdomain_routinghotthe host → registry routing table
air_gappartialthe registry clients' air-gap wrapper; warming and release imports keep the startup clients
limits.max_artifact_size_bytespartialthe request path; the scan worker keeps the startup limit
proxypartialthe registry clients and cargo index; the README fetcher and warming keep the startup proxy
registries[*]partialthe registry clients, policies and maps; warming and release imports keep the startup client
registries[*].auto_wire.registry_upstreampartialthe overlay's archive upstream; a held copy under the old URL is not reused
registries[*].cache.artifact_ttl_secspartialthe registry's download policy; eviction keeps the startup TTL
registries[*].cache.metadata_ttl_secspartialthe registry's metadata policy; warming keeps the startup client
registries[*].cacherestartthe warming and eviction services, built once
registries[*].quotarestartthe quota service, built once
registries[*].rate_limitrestartthe rate limiter, built once
registries[*].security.rescanrestartthe rescan scheduler, started at startup only when a registry already had one
registries[*].storagerestartthe storage router, built once
everything elserestartread once at startup

Adding or removing a whole registry is partial: the request path serves it at once; warming, eviction, rate limits, quota and the metric labels keep the startup list, so the restart-only keys an added registry carries — rate_limit, quota, storage, cache.idle_days — are listed under restart_required beside it.

On an instance started with BATLEHUB_DISABLE_HOT_RELOAD=1, every change is a restart, whatever the table says.

What a reload reports ​

Every diff — the pending reload, POST /api/v1/admin/config/validate, the immediate reload — carries three lists of dotted paths, an array entry named by its name (or type): registries[npm].upstreams.

FieldContainsCompared against
appliedhot keys this candidate changesthe config in force
partially_appliedpartial keys this candidate changesthe config in force
restart_requiredevery restart key the running process does not havethe config the process started on

restart_required is compared against startup on purpose: a database.url change applied an hour ago is still listed on every later reload, until the restart that makes it true. The file watcher logs it at WARN, and the Config Reload page shows the three lists.

restart_required is ["*"], with the reason in restart_reason, when the configuration places a ${VAR} where the diff cannot keep it as text — outside a one-line string value, in a key, or in the name or type of any [[…]] entry — [[registries]], [[auth]] and the rest (see Inline substitution). restart_reason names the side that could not be compared: the candidate, the config in force, or the startup config. Only that comparison is unknown, and unknown is a restart; the other lists are still filled, and the reload itself goes on as before.

9.1 File Watcher ​

When the config file changes on disk, BatleHub automatically validates the new config (schema check + connectivity probes) and stores a pending reload. The admin then confirms or discards it via the UI or API. Pending reloads expire after 10 minutes.

When the process was started with more than one --config, every layer is watched and every reload re-reads all of them. Rotating a credential touches only the credentials file, and that alone stages a pending reload: the byte-identical-rewrite dedup that exists for touch and atomic saves compares all the layers, not just the first. See Layered config files.

A layer that cannot be watched is logged and skipped rather than taking the watcher down for the others; the reload path re-reads every layer anyway, so a change to a watched file still picks up whatever the unwatched one now says.

The file watcher is enabled by default. Disable it with:

sh
BATLEHUB_DISABLE_HOT_RELOAD=1 batlehub --config config.toml

Use this when config.toml is mounted as a read-only Kubernetes ConfigMap.

9.2 API Endpoints ​

MethodPathDescription
POST/api/v1/admin/config/reloadImmediate reload: validate + apply atomically
GET/api/v1/admin/config/pendingGet pending reload diff (404 if none)
POST/api/v1/admin/config/pending/applyApply the pending reload
DELETE/api/v1/admin/config/pendingDiscard the pending reload
GET/api/v1/admin/config/changesPaginated audit history (?page=0&per_page=50)
GET/api/v1/admin/config/warningsNon-fatal problems with the config currently in force
sh
# CI/CD: apply a new config atomically
curl -s -X POST \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  http://localhost:8080/api/v1/admin/config/reload

# Two-step flow: let the file watcher load a pending, then apply from CI
curl -s -X POST \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  http://localhost:8080/api/v1/admin/config/pending/apply

All reloads (applied or rejected) are written to the config_changes table with the diff, trigger source, and operator identity.

The config editor and several replicas ​

The file stays the source of truth, and an apply from the console's config editor is refused rather than half done:

  • The file is written before anything is applied. If it cannot be written — a read-only mount such as the chart's Secret — the apply answers 500 and the replica keeps the configuration it had. Edit the file at its source instead, or give the server a writable file (the chart's writableConfig).
  • An apply names the change it applies. from-content returns the staged change's pending_id and POST …/pending/apply takes it back ({"pending_id": "…"}); when another admin staged a change since, the apply answers 409 and leaves theirs staged. The body is optional: without it the apply takes whatever is staged, as before.
  • A save never overwrites a newer file. GET …/config/content returns a content_hash; sent back as from-content's base_hash, a file that changed since is answered with 409, at staging and again at apply.
  • The other replicas follow. An apply announces the hash of the file it put in force through the database every replica already polls (every 15 s). A replica that reads it applies its own file once that file has the same hash — through a shared volume, or once a Secret update reaches the pod — and gives up after two minutes; the config.replica-drift warning then says which replicas differ. A change staged but not applied on a follower is replaced by the followed one.

Config warnings ​

Some config states are wrong enough to tell an operator about but not wrong enough to refuse to start — a registry name that cannot become a DNS label, a deprecated key being shadowed, a permissive security default left in place. These are logged at startup and on every reload, and served from GET /api/v1/admin/config/warnings so they can be seen without grepping logs:

json
{
  "warnings": [
    {
      "code": "proxy-trust.unconfigured",
      "path": "server.trusted_proxies",
      "message": "no trusted-proxy list is configured, so Forwarded / X-Forwarded-Host / …"
    }
  ]
}

code is a stable slug, safe to match on; path points at the offending config location verbatim, so it can be searched for in the TOML.

POST /api/v1/admin/config/validate and POST /api/v1/admin/config/from-content return the same shape inline under warnings, describing the candidate config — so an admin sees them before applying a pending reload rather than after. The Configuration admin page renders both.

CodeMeaning
console.unknown-warningA warning:<code> in [console].accepted names no code this release raises: a typo, or a newer release's code during a rollout
proxy-trust.unconfiguredNo trusted_proxies list anywhere; forwarded host/scheme are believed from any client
proxy-trust.deprecated-key-onlyProxy trust comes from the deprecated [ip_blocking].trusted_proxies
proxy-trust.invalid-deprecated-entryAn entry of the deprecated [ip_blocking].trusted_proxies is not an IP or CIDR range and was dropped
proxy-trust.shadowed-deprecated-keyBoth keys are set; [server] wins and the deprecated list is ignored entirely
stats.monitoring-url-httpA [stats] monitoring link uses http; the browser follows it in clear text
subdomain.invalid-dns-label[subdomain_routing] is on but a registry name cannot be a DNS label, so no wildcard host is derived for it
vsx-signing.proxy-mode[registries.vsx_signing] on a registry in proxy mode: nothing is published there, so the key signs nothing; the upstream's signature is relayed regardless

9.3 Global Admin Banner ​

Administrators can broadcast a message to all website visitors:

sh
# Set a warning banner
curl -s -X PUT \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"message":"Maintenance window in 30 min","level":"warning"}' \
  http://localhost:8080/api/v1/admin/banner

# Clear it
curl -s -X DELETE \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  http://localhost:8080/api/v1/admin/banner

The frontend polls GET /api/v1/banner (no auth required) every 30 seconds. The banner backend uses the same infrastructure as the metadata cache:

[cache] typeBanner storage
"memory"In-process — not shared across replicas
"redis"Redis — shared across all HA replicas
"postgres"system_kv table — shared across all HA replicas

Released under the Apache 2.0 License. Made with care and too much coffee.