Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Environment variables

The Rust services take their settings from environment variables. On an edge node you never set these by hand: render-edge-config.py writes them from the box profile into /etc/avena-rs/<service>.env.json, and avena-service-run.sh exports them before starting the binary. Relative paths in NATS_CREDS_FILE, OUTPUT_DIR and PARQUET_DIR are resolved against the folder holding avena-service-run.sh: /usr/local/libexec/avena-rs on an installed box, rust-ljm when it is run from a checkout. The profiles use absolute paths, so this rarely matters.

The tables list what each binary actually reads, with the default the code uses when the variable is unset.

Shared by all services

VariableDefaultMeaning
NATS_SERVERSnats://127.0.0.1:4222Comma-separated URLs of the local NATS server.
NATS_CREDS_FILEapt.credsCredentials file for that connection.
JS_DOMAINdefault domainThe box’s JetStream domain, e.g. edge-i69-mu1. Read by the streamer and the archiver; the exporter uses core NATS only.

streamer

VariableDefaultMeaning
CFG_BUCKETavenaboxLocal key-value bucket holding the configuration.
CFG_KEYunknown-site.macbook.unknown-source.configKey of this box’s configuration. Always set it.
CENTRAL_NATS_SERVERSunsetCentral NATS URLs to mirror the configuration from. Mirroring is off when neither this nor CFG_NATS_SERVERS is set.
CFG_NATS_SERVERSunsetFallback for CENTRAL_NATS_SERVERS. This is the one the renderer sets.
CENTRAL_NATS_CREDS_FILENATS_CREDS_FILECredentials for the central connection.
CENTRAL_CFG_BUCKETCFG_BUCKETCentral bucket to mirror from.
CENTRAL_CFG_KEYCFG_KEYCentral key to mirror from.
CENTRAL_JS_DOMAINCFG_JS_DOMAINJetStream domain on the central server, if any.
STREAM_MAX_BYTESunlimitedSize limit of the JetStream stream, in bytes. When full, the oldest messages are discarded.
LABJACK_IPnone, requiredIPv4 address of the LabJack T7.
LABJACK_IDENTIFIERunsetUsed instead of LABJACK_IP only if it is an IPv4 address.
LABJACK_SERIALunsetExpected serial number. A device with a different serial is refused. ANY or a non-number turns the check off.
LABJACK_NAMEunsetName used in log messages.
STREAMER_MAX_LABJACK_FAILURES5Consecutive failures after which the streamer exits and stays stopped.
STREAMER_LABJACK_RETRY_DELAY_SECS5Wait before retrying after a failure, in seconds.
LJM_PATHunsetPath to libLabJackM.so, if it is not on the library path.

The streamer takes its identity (site, box, source, channels, rates) from the configuration document, not from the environment. The renderer also writes ASSET_NUMBER, SITE_ID, BOX_ID, SOURCE_TYPE, SOURCE_ID, OUTPUT_DIR, EXPORTER_HTTP_URL, LABJACK_USB_ID and LABJACK_OPEN_ORDER into streamer.env.json; the streamer does not read them.

archiver

VariableDefaultMeaning
PARQUET_DIRparquetRoot of the archive.
CFG_BUCKETavenaboxLocal key-value bucket holding the configuration.
CFG_KEYlabjackd.config.macbookKey of the configuration to follow. Always set it.
CENTRAL_NATS_SERVERS, CFG_NATS_SERVERS and the other CENTRAL_* variablesas for the streamerOptional configuration mirror, same behavior as the streamer.
ARCHIVER_STATE_DIR.archiver-state under PARQUET_DIRWhere each channel’s replay-guard checkpoint is kept.
ARCHIVER_REPLAY_GUARDonoff (or 0, false, no) turns off the guard that skips messages already archived when JetStream loses a consumer’s progress.

The renderer also writes NATS_SUBJECT, SITE_ID, BOX_ID, SOURCE_TYPE and SOURCE_ID into archiver.env.json. The archiver does not read them; like the streamer, it takes its channels and subjects from the configuration document.

exporter

VariableDefaultMeaning
EXPORTER_MODEworkerworker answers requests over NATS. direct (or local) serves a WebSocket instead.
EXPORTER_ADDR0.0.0.0:9001Listen address in direct mode only.
PARQUET_DIRparquetRoot of the archive to read.
NATS_SUBJECTavenarsFirst token of the request subject.
SITE_IDunknown-siteSite token of the request subject.
EXPORT_BOX_ID or BOX_IDnone, required in worker modeBox token of the request subject.
SOURCE_IDunsetSource token of the request subject.
LABJACK_NAMEunsetSource token when SOURCE_ID is unset.
ASSET_NUMBERunsetSource token asset<NNN> when SOURCE_ID and LABJACK_NAME are unset; with none of the three the token is unknown-source. This is the same fallback the streamer and the webapp use.
SOURCE_TYPElabjackRead but currently not used in the subject.

In worker mode the exporter subscribes to <NATS_SUBJECT>.<SITE_ID>.<BOX_ID>.<SOURCE_ID>.export.request, so these values must match the box’s configuration exactly.

subscriber

subscriber is a diagnostic tool and reads its settings from the environment as well; see Command-line tools.