Mirexa

Wiki Reference

mirexa-server

The Mirexa node binary — its flags, environment overrides, signals, exit statuses, the listeners it opens and the files it writes.

mirexa-server is the Mirexa node: one process that takes writes, answers queries, serves subscriptions and, when clustering is on, takes part in the control plane and replication. Every node runs the same binary. This page is the reference for how it is started and stopped; what to put in its configuration is on the configuration reference, and the order of what happens at startup and shutdown is on Startup, shutdown and recovery.

Names

The source is /cmd/server. make build runs go build -o bin/ ./cmd/..., which writes it as bin/server; the container image installs it as /usr/local/bin/mirexa-server and starts it with -config /etc/mirexa/node.yaml.[1] Both are the same program. Its own error messages begin mirexa:.

Usage

bash
mirexa-server -config /etc/mirexa/node.yaml
bash
mirexa-server -data-dir /var/lib/mirexa
Flag Default Meaning
-config PATH none YAML configuration file. Without it the node runs on built-in defaults plus environment overrides. With it, the file is also watched for changes.
-data-dir PATH none Overrides storage.data_dir.
-h, -help Prints the flag list and exits 0.

There are no other flags; everything else is configuration.

How the configuration is resolved

In order, each later source overriding the earlier:[2]

  1. built-in defaults (config.Default);
  2. the YAML file, if -config is given;
  3. MIREXA_* environment variables;
  4. -data-dir.

The result is then validated as a whole, and the node refuses to start on an invalid configuration or with no data directory at all ("no data directory: set storage.data_dir in the config file or pass -data-dir"). An environment variable that does not parse is a warning on standard error ([config warning] ...), not a failure: the variable is ignored. TestLoad_Precedence and TestDefaultWithEnv_AppliesEnv cover the ordering.

Environment variables

Only these settings can be overridden from the environment (the list is what /internal/config/loader.go reads):

Section Variables
partition MIREXA_PARTITION_COUNT
network MIREXA_NETWORK_ADDR, _READ_TIMEOUT, _WRITE_TIMEOUT, _IDLE_TIMEOUT, _CONNECTION_TIMEOUT, _SHUTDOWN_TIMEOUT, _MAX_CONNECTIONS, _BUFFER_SIZE, _MAX_FRAME_PAYLOAD_BYTES, _SUBSCRIPTION_MAX_PER_CONNECTION, _SUBSCRIPTION_QUEUE_DEPTH, _SUBSCRIPTION_DROP_LIMIT, _SUBSCRIPTION_OFFLOAD_ABOVE (each prefixed MIREXA_NETWORK)
observability MIREXA_OBSERVABILITY_ADDR, _READ_TIMEOUT, _WRITE_TIMEOUT, _SHUTDOWN_TIMEOUT
storage MIREXA_STORAGE_DATA_DIR, MIREXA_STORAGE_COMPACTION_ENTRY_THRESHOLD, MIREXA_STORAGE_COMPACTION_INTERVAL
compression MIREXA_COMPRESSION_ALGORITHM
security MIREXA_SECURITY_TLS_ENABLED, _CERT_FILE, _KEY_FILE, _CA_FILE, _CLIENT_AUTH, _MIN_VERSION, _CIPHER_SUITES (each prefixed MIREXA_SECURITY)
wal MIREXA_WAL_SHARD_COUNT, _SYNC_POLICY, _SYNC_INTERVAL, _FLUSH_INTERVAL, _BATCH_SIZE, _MAX_SEGMENT_BYTES, _RETAIN_SEGMENTS, _MAX_BUFFER_BYTES, _BUFFER_WAIT_TIMEOUT, _MAX_RETRIES, _RETRY_BASE_DELAY (each prefixed MIREXA_WAL)
ingestion MIREXA_INGESTION_LIVE_CANDLE_CACHE_ARENA_CAPACITY, _LIVE_CANDLE_CACHE_SPAN, _LIVE_CANDLE_CACHE_HOT_CACHE_SIZE, _LIVE_CANDLE_FLUSH_INTERVAL, _LIVE_TICK_CACHE_ARENA_CAPACITY, _LIVE_TICK_CACHE_HOT_CACHE_SIZE, _LIVE_TICK_FLUSH_INTERVAL, _HISTORY_ARENA_CAPACITY, _HISTORY_WORKER_COUNT, _HISTORY_QUEUE_DEPTH (each prefixed MIREXA_INGESTION)
logging MIREXA_LOGGING_LEVEL, _ENCODING, _OUTPUT, _MAX_SIZE_MB, _MAX_BACKUPS, _MAX_AGE_DAYS, _COMPRESS, _SAMPLE_INITIAL, _SAMPLE_THEREAFTER (each prefixed MIREXA_LOGGING)

Authentication, the control listener, clustering and the dashboard have no environment overrides; set them in the file. Durations take Go syntax (30s, 5m).

What it opens

Listener Setting Default Notes
Wire protocol (data) network.addr :8080 Writes, queries, subscriptions. TLS when security.tls_enabled.
Metrics and probes observability.addr :9090 GET /metrics, /health (liveness), /ready (readiness). Binds every interface by default.
Control (gRPC) control.addr 127.0.0.1:9091 Only when control.enabled. See Control-plane gRPC API.
Consensus (Raft) cluster.raft_addr none; required when clustering is on Only when cluster.enabled.
Replication (mTLS gRPC) cluster.replication_addr none Only on a clustered node that sets it; mutual TLS with node certificates from mirexa-cli certs.

Two of a node's listeners on one port are refused when the configuration is validated, and a metrics listener that cannot bind stops the node at startup rather than leaving it running without /metrics, /health or /ready.[3]

/ready reports the data listener's own state and free space in the data directory, and turns false at the first step of a shutdown so a load balancer stops routing there before the data plane goes away.

Signals

Signal Effect
SIGTERM, SIGINT Graceful shutdown (below), then exit 0.
SIGHUP Reload; never stops the node. Logs "SIGHUP received: reloading the config file and any TLS certificates; the node keeps running", re-reads the configuration file at once (with -config), and reloads the data listener's TLS certificate and key from their files, when security.tls_enabled, and the replication listener's node certificate, when clustering is on. Live connections keep the certificate they handshook with; new handshakes get the new one. A failed reload is printed to standard error ([tls error] certificate reload failed: ...) and the old certificate stays in use.

SIGHUP is caught from the start of the process to its end, on every node.[4] Until 2026-10-30 only the certificate reloaders caught it, so on a node with security.tls_enabled: false and clustering off it ended the process at once, with no drain and no handoff (TestServerBinary_SIGHUPReloadsAndNeverStopsTheNode).

With -config the file is also watched, so a change is picked up without a signal; SIGHUP makes it immediate, which matters for a file that is a symlink into another directory (a Kubernetes ConfigMap mount), whose change no file event names. Of every setting only logging.level is applied while running; any other change is logged at WARN as "config changes require a restart to take effect", naming the fields.[5]

Graceful shutdown

On SIGTERM or SIGINT the node stops in this order:[6]

  1. readiness turns false;
  2. handoff: writes for placed partitions are refused, writes already admitted finish, and the node waits — up to network.shutdown_timeout (30s) — until every copy tailing it has been sent everything it made durable; on timeout it logs an ERROR naming how many copies were behind, and goes on;
  3. the WAL checkpoint loop stops;
  4. the cluster planes stop (replica supervisor, joiner, replication listener) while the data path still works;
  5. the data listener stops accepting and drains its connections, waiting up to network.shutdown_timeout;
  6. the control listener stops, then the Raft node;
  7. every stream's in-memory data is written to chunks;
  8. the metrics server stops last.

Only step 7 can fail the shutdown. TestShutdown_TheClusterPlanesStopWhileTheDataPathStillServes pins the order of the cluster planes, and TestServerBinary_ASigtermedPrimaryUnderLoadLosesNoAckedWrite shows a primary stopped under load loses no acknowledged write to its copy.

Two costs are known and unchanged. A connection that is open but idle (a routing client, a dashboard, a quiet subscriber) is waited on for the whole of network.shutdown_timeout before it is closed, so a node with any connected client takes about that long to stop. And step 7 writes each stream's data one stream at a time — measured at about 45 ms a stream (1,000 streams, 45.4 s, 2026-10-20, on a developer laptop's NVMe with other work running) — so a node holding many streams can outlast an orchestrator's grace period. Killed during it, the node loses nothing acknowledged; recovery at the next start is slower. See Known limitations.

Exit status

Status When
0 A clean shutdown after SIGTERM/SIGINT.
0 The node was decommissioned: its drain finished, the cluster removed it, and its registration was refused with the final answer. It logs "this node has been decommissioned and has left the cluster; shutting down" and stops through the ordinary shutdown. Restarted afterwards on its old data directory, it logs "...; not starting" and exits 0 again without serving (TestServerBinary_ADecommissionedNodeExitsOnItsOwn).
0 -h.
1 Any startup failure (invalid configuration, a TLS file or keyring that will not load, a failed consensus start or admission, an unreadable WAL, a port already in use on the data or control listener), or a failure writing data to chunks during shutdown. The reason is printed to standard error as mirexa: <reason>.
2 A flag the parser does not know (the standard library's flag behaviour).
by signal An unhandled signal, such as SIGKILL. Recovery replays the write-ahead log at the next start (TestCrash_KillDashNine).

A clustered node never falls back to running alone: a failed consensus start or a failed join is fatal, because a node that silently ran standalone would acknowledge writes for a cluster it is not part of. See Joining, draining and decommissioning nodes.

Files it writes

Everything lives under storage.data_dir. The layout, formats and magic numbers are on Indexes and the on-disk layout and On-disk formats; in brief:

Path What
streams.meta The node's stream catalog and each stream's metadata (calendar, closures, lineage, cache size).
wal/ The write-ahead log: wal.lock (an exclusive lock, so two processes never share a directory), numbered segment files, shard_<n>/ tick logs, and quarantine.floors.
partition_<id>/ Each partition's streams: chunk files, stream.idx, gap.idx, tick storage; on a copy, also its replica logs.
quarantine/ Partition directories moved aside — a divergent copy, a partition this node no longer holds a role in, or one whose index was corrupt at startup. Nothing deletes them; an operator removes them.
raft/ Only when clustering is on: the consensus log and snapshots.

Outside the data directory it writes only its log, to standard error by default (logging.output may name a file instead, rotated by logging.max_size_mb, max_backups and max_age_days).

References

Source

Tests

Further reading

External

  • Package os/signal — default behavior of signals in Go programs, The Go Authors — https://pkg.go.dev/os/signal#hdr-Default_behavior_of_signals_in_Go_programs
  • Package flag, The Go Authors — https://pkg.go.dev/flag

  1. the build target in /Makefile; the server stage of /Dockerfile. ↩︎

  2. buildConfig in /cmd/server/main.go; Load and DefaultWithEnv in /internal/config/loader.go. ↩︎

  3. config.Default in /internal/config/config.go; the shared-port check in /internal/config/validate.go; startObservabilityServer in /cmd/server/main.go over observability.Server.Listen (/internal/observability/server.go); TestServerBinary_ANodeThatCannotBindItsObservabilityPortDoesNotStart. ↩︎

  4. catchHangup in /cmd/server/main.go, called at the start of run, and config.Watcher.Trigger in /internal/config/loader.go; the certificate reloaders subscribe to the same signal in CertReloader.WatchSIGHUP (/internal/network/tls.go), which buildTLS calls only when TLS is enabled, and NodeTLS.WatchSIGHUP on the replication listener (/cmd/server/replication.go). ↩︎

  5. hotReloadable and watchConfig in /cmd/server/main.go. ↩︎

  6. shutdown and its doc comment in /cmd/server/main.go. ↩︎