# Server flags and configuration

> scada-server command-line flags, environment variables, the config.yaml file and the network ports eaxScada uses.

Product: eaxScada · Type: Reference · Editions: Starter, Pro, Enterprise
Source: https://eaxware.com/docs/eaxscada/reference/server-configuration/
Status: migrated page, not yet verified against the current code.

## 1. Command-line flags

The `scada-server` binary (`eaxscada.exe` in the release package) accepts these flags. The generated CLI reference will replace this table.

| Flag | Default | Description |
|---|---|---|
| `-config` | `""` | Path to the YAML configuration file. |
| `-workdir` | current directory | Directory holding `config/`, `data/`, `logs/` and `web/`. As a Windows service, the executable's directory. |
| `-tier` | | Lowers the edition, for testing only: `free`, `starter` or `pro`. It never raises the edition, which comes from the licence (see [Edition and licence](#4-edition-and-licence)). Any other value is ignored with a warning. |
| `-plc-url` | `http://localhost:8085` | URL of the companion eaxPLC runtime. |
| `-plc-id` | `plc-01` | ID of the companion eaxPLC runtime on the NATS bus. |
| `-plc-nkey-seed` | created under `data/security/nkeys` | Provisioned eaxPLC NATS seed file shared by both HA nodes. The file must exist. |
| `-edge-plcs` | `$EAX_EDGE_PLCS` | Comma-separated IDs of eaxPLC edge runtimes this server works with. Each one connects with its own seed, created under `data/security/nkeys/<id>.nk`. |
| `-edge-plc-seed-dir` | `$EAX_EDGE_PLC_SEED_DIR` | Directory of provisioned edge PLC seeds (`<id>.nk`) shared by both HA nodes. The directory must exist. |
| `-nats-watcher` | `$EAX_NATS_WATCHERS` | A read-only identity on the broker, `name=<public key or seed file>`. Repeatable, or several separated by commas. A watcher may only subscribe to `plc.*.birth`, `plc.*.status` and `uns.telemetry.>` and publishes nothing. See [NATS identities on the broker](#nats-identities-on-the-broker). |
| `-gen-device-seed` | | Write a new device NATS seed to this file (mode 0600, never overwrites), print its public key and exit. |
| `-ha-role` | | Initial HA role: `primary`, `standby` or `witness`. |
| `-node-id` | auto-assigned | Unique HA node identifier. |
| `-witness` | `false` | Start as a lightweight HA witness: NATS cluster quorum only, with no web UI, drivers or tag engine. |
| `-version`, `-v` | | Print the binary version and build flavour (`full` or `standard`), then exit. |

Go flags accept one or two dashes: `-workdir` and `--workdir` are the same flag.

### Environment variables

| Variable | Effect |
|---|---|
| `SCADA_PORT`, then `PORT` | Web port. Overrides `server.port`. |
| `EAX_EDGE_PLCS` | Default for `-edge-plcs`. |
| `EAX_EDGE_PLC_SEED_DIR` | Default for `-edge-plc-seed-dir`. |
| `EAX_PLC_NKEY_SEED_FILE` | Default for the eaxPLC seed file. |
| `EAX_NATS_WATCHERS` | Default for `-nats-watcher`: one or more `name=<public key or seed file>`, separated by commas. The first `-nats-watcher` on the command line replaces the whole list. |
| `EAX_DEV_MODE` | `1`, `true` or `yes` enables developer mode (see below). Never on a plant system: it also creates the development accounts with published passwords (`admin/admin123`, `engineer/engineer123`, `supervisor/supervisor123`, `operator/operator123`, `auditor/auditor123`, `ai_copilot/copilot123`) that are missing, offers them on the sign-in page and does not require a password change. The log flags them as unsafe. |
| `EAX_ADMIN_PASSWORD_FILE` | A new installation only: file holding the first password of `admin` (at least 12 characters), instead of a random one in `data/security/initial_admin_password`. See [First sign-in](/docs/platform/how-to/install/#64-first-sign-in). |
| `EAX_ADMIN_PASSWORD` | A new installation only: the first password of `admin` itself. Prefer `EAX_ADMIN_PASSWORD_FILE`. Setting both stops the server. |
| `EAX_ADMIN_PASSWORD_CHANGE_REQUIRED` | `true` (default): `admin` must change a password given by the two variables above at the first sign-in. `false` lets it keep that password; it never applies to a generated password. |
| `EAX_ASSISTANT_ENABLED` | `false` switches the AI assistant off (Pro and Enterprise). Overrides `assistant.enabled`. See [Switching the AI assistant off](#switching-the-ai-assistant-off). |
| `EAX_STUDIO_DEFAULT_SCREEN` | The screen the Designer and a plain `/runtime` open first. Overrides `studio.default_screen`. |
| `EAX_LOG_FILE` | The log file. Overrides `logging.file`. See [Log file](#log-file-loggingfile-loggingfile_enabled). |
| `EAX_LOG_FILE_ENABLED` | `false` writes no log file. Overrides `logging.file_enabled`. |
| `SCADA_TIER` | No longer used. The server logs that it is ignored: the edition comes from the licence. |

### NATS identities on the broker

The embedded broker admits only identities the server knows. Everything else is refused and recorded as `NATS_AUTH_REJECTED`, at most once a minute per client name and address (every rejection is still written to the server log). A user connection already open is closed when the user's rights change ([Broker connections](/docs/platform/explanation/security-and-part-11/#47-broker-connections)).

| Identity | Set by | What it may do |
|---|---|---|
| The server itself | a key generated at each start | everything the server needs |
| The companion eaxPLC | `-plc-id`, `-plc-nkey-seed` (`EAX_PLC_NKEY_SEED_FILE`) | its own `plc.<id>.>` subjects, publish UNS telemetry, receive UNS commands |
| eaxPLC edge runtimes | `-edge-plcs`, `-edge-plc-seed-dir` | the same, each for its own id |
| Watchers | `-nats-watcher` (`EAX_NATS_WATCHERS`) | subscribe to `plc.*.birth`, `plc.*.status` and `uns.telemetry.>`; nothing else |
| Users | their account: a registered NKey, a session token, or username and password | their role's subject permissions |

**Watchers** are for programs that only watch the PLCs' announcements and the UNS telemetry, such as the UNS prefix guard of an eaxsim host (see [Connect an eaxsim host to eaxScada's broker](/docs/eaxscada/how-to/connect-an-eaxsim-host/)).

- **Value:** `name=<key>`. The name is letters, digits, `-` and `_`. The key is either a user public NKey (`U...`), kept as it is, or the path of a seed file, which must exist; only its public key is kept. `-gen-device-seed <file>` makes a seed and prints its public key.
- **Subscribe:** only `plc.*.birth`, `plc.*.status` and `uns.telemetry.>`. Not the UNS commands, not the PLC API, not `plc.*.death`, not inboxes, nothing else.
- **Publish: nothing.** Publishing is denied on every subject: no telemetry, no UNS command, no PLC API call, no request. A watcher has no reply permission either, so it answers no request.
- **One key, one role.** A key that is already the server's own, a PLC's (companion or edge) or another watcher's is refused. Give each watcher its own key, never a PLC's seed.
- **A bad value stops the start.** A name given twice, an invalid name, a value without `=`, a key that is not a user public NKey and not a readable seed file, or a key already in use: the server logs `invalid --nats-watcher` with the reason and does not start.
- **Logged and audited:** at start the log names each watcher and its public key ("NATS watcher identity"). Each connection logs "watcher connected" and is recorded as `NATS_WATCHER_CONNECTED`, with the user `watcher-<name>` and the client address.
- **High availability:** give both nodes the same watcher, with the same public key or the same provisioned seed file, so the program is admitted by whichever node is active.
- **Nothing else changes:** without `-nats-watcher` the broker admits exactly what it did before, and the PLC and user identities keep their rights.

Example: `eaxscada --nats-watcher eaxsim=UB4K...` (or `EAX_NATS_WATCHERS=eaxsim=UB4K...`), the public key printed by `eaxscada --gen-device-seed eaxsim-guard.nk`.

---

## 2. Configuration file (`config.yaml`)

An annotated example with the defaults of a new installation (the file the server writes on its first start holds the same keys, with more comments). Every key the server reads, with its type, is in the [generated configuration reference](/docs/eaxscada/reference/generated/config/server-config/). Driver channels are not set here: they are in `data/drivers/config.json`, edited on the **Drivers** page.

The file does not set the edition. An older file's `tier:` line is read and ignored, and the server logs that it is ignored.

```yaml
server:
  host: "127.0.0.1"          # "0.0.0.0" to accept connections from other machines
  port: 8080
  web_dir: "./web"
  # allowed_origins:         # other browser origins that may open /ws and send state-changing requests with the cookie
  #   - "https://hmi.plant.example"
  # trusted_proxies:         # reverse proxies whose X-Forwarded-* headers are believed
  #   - "127.0.0.1/32"
  ws_max_per_session: 8      # concurrent /ws sockets per session
  ws_max_per_ip: 32          # concurrent /ws sockets per client address
  # ws_send_queue: 4096      # messages a /ws socket may lag behind (then closed with 1013)
  # ws_batch_ms: 100         # tag updates batched per /ws socket (50-1000 ms)
  # ws_max_tags: 50000       # tags one /ws socket may subscribe to (at most 500000)
  # ws_max_views: 256        # views one /ws socket may subscribe for (at most 4096)
  # ws_max_prefixes: 16      # prefix entries (Plant/Line1/*) one view may hold (1-256)

nats:
  host: "127.0.0.1"          # "0.0.0.0" for external UNS access
  port: 4222
  http_port: 8222
  http_host: "127.0.0.1"     # NATS monitoring has no authentication: keep it local
  telemetry_buffer: 64MB     # in-memory replay buffer of uns.telemetry.> (10 min at most; at least 1MB)
  # start_timeout: 10s       # wait for the embedded broker at start (at least 1s; raise on a slow machine)

cluster:                     # NATS clustering (Enterprise for 2 nodes)
  enabled: false
  name: "eaxscada-mesh"
  port: 4248

tag_engine:
  capacity: 100000
  deadband_default: 0.05
  max_tags: unlimited        # unlimited in every edition

historian:
  engine: "duckdb"           # the columnar engine: the release server, every edition; "hive_csv" in builds without the embedded database
  path: "./data/historian"
  tde_encryption:
    enabled: false           # encryption at rest
    cipher: "aes-gcm-256"
    key_env: "EAX_HISTORIAN_TDE_KEY"
  retention: 90d
  max_size: 50GB
  disk:
    warn_free: 15%
    critical_free: 5%, 5GB
    purge_on_critical: true
    pause_on_critical: true
  store:                     # the columnar store (full build)
    memory_limit: 1GB        # without it: 25% of the RAM, at least 512MB, at most 4GB
    threads: 2               # without it: one per 64 MiB of the cap, at most every core
  logging:                   # tags without a historian logging rule
    default_min_interval: 1s
    default_deadband: 0
    default_max_interval: 10m
  snapshot:                  # nightly copy of the columnar store; on without the section
    enabled: true
    schedule: "01:30"        # local time
    dir: "./data/backup/historian"
    keep: 2
  export:                    # daily Parquet export: Pro, Enterprise
    schedule: "02:00"        # without enabled: on (store without encryption at rest)
    dir: "./data/historian_export"
    format: parquet          # without keep_days: the historian's retention
    compress: true

health:
  interval: 10s
  cpu_high_percent: 90
  cpu_high_for: 10m
  memory_low_percent: 10
  memory_low_for: 1m

security:
  data_dir: "./data/security"
  audit_data_dir: "./data/audit"   # the audit trail, audit.duckdb (Starter, Pro, Enterprise): a local disk, outside the historian folder

metrics:
  enabled: true
  allow_localhost: false
  history_interval: 10s
  history_retention: 72h

licence:
  file: "./data/licence/licence.json"   # the default; verified at every start

assistant:
  enabled: true              # false: the AI assistant is switched off on this server

logging:
  level: info                # debug, info, warn, error
  console_format: text       # text or json (the console only)
  file: "logs/eaxScada.log"  # the log file, always JSON lines; relative to the work directory
  file_enabled: true         # false: no log file (console, log table and syslog stay)
```

### How eaxScada reads config.yaml

**Each key is read in the section its indentation puts it in.** The server follows the file's indentation as YAML nests it: a key written after a sub-section, back at its section's indentation, belongs to the section again. Releases before 16 November kept the last sub-section open until the next section header. These now read differently:

1. `nats.port` after `nats.cluster:` sets the NATS server's port. It was read as the cluster's port, and the NATS server stayed on its default port.
2. `nats.host`, `nats.http_port` and `nats.http_host` after `nats.cluster:` are read. They were ignored.
3. `nats.leaf_nodes` written on one line (`leaf_nodes: ["nats-leaf://hub:7422"]`) after `nats.cluster:` is read. It was ignored.
4. `logging.level` after `logging.syslog:` sets the main log level. It was read as the syslog level.
5. The log file keys (`logging.file`, `logging.file_enabled`) after `logging.syslog:` are read. They were ignored.
6. A section's keys after a sub-section the server does not read are read: `server.host` and `server.port` below an unread `tls:` block, for example. They were ignored, and the server kept its default address and port.
7. A top-level `tier:` after a section is read (it was ignored); a `tier:` inside a section is not. `tier` never sets the edition.
8. A known key below a header the server does not read is ignored, and named at start-up. Under `metrics:` `extra:` `server:`, a `port:` was read as `server.port`.
9. A known sub-section nested deeper than its place (`historian:` `disk:` `store:`, for example) is ignored, and named at start-up. It was read as the sub-section of that name.

Every shipped sample, template and installer output reads the same as before. Check your own file if it writes keys after a sub-section, or nests sections in other places.

**Unknown keys are named at start-up.** A key no part of the server reads (a typo, a key of another release) gets one `WARN` line in the log at start-up, with its line number, and with a suggestion when a known key is close (at most two letters apart, or a key of the same name in a sub-section):

```
unknown configuration key historian.retenion at line 41 is ignored; did you mean historian.retention?
unknown configuration section server.tls at line 3 is ignored with the 2 keys under it
configuration key nats.routes at line 18 is not read on one line; write each entry as a "- " item below nats.routes:
```

Each is the message of a `WARN` line of the component `config`, with the fields `file`, `line` and `key`.

- An unknown section is named once, with the number of keys under it, not key by key.
- `nats.routes:` and a top-level `routes:` are lists of cluster routes, read as `- ` items below the key. Written on one line (`routes: [a, b]`), they are not read, and the line says so.
- `reports.shifts` holds calendars you name: nothing under it is flagged.
- The server always starts: an unknown key is never an error, and no setting changes because of the warning. The start-up line `eaxScada starting` gives the count as `unknown_config_keys`.

**The sample files hold only keys the server reads.** The shipped sample `config.yaml` files (the full-build Docker image, the Windows sample, the standard-build image) and the file the server writes on its first start set no edition (it comes from the licence) and no account or password: at the first start the server creates `admin` with a random password, written once to `data/security/initial_admin_password`, or takes it from `EAX_ADMIN_PASSWORD_FILE`, and asks for a new one at the first sign-in. See [First sign-in](/docs/platform/how-to/install/#64-first-sign-in).

### Other origins (`server.allowed_origins`)

`server.allowed_origins` lists browser origins besides the server's own, each `scheme://host[:port]` (the scheme and port count). Pages of those origins may open the `/ws` live-data socket and send requests that change something (`POST`, `PUT`, `PATCH`, `DELETE`, sign-in included) with the session or station cookie. From any other origin, such a request is refused with `403`, code `cross_origin`, and recorded as `CROSS_ORIGIN_REFUSED` (at most once a minute per address). The server's own origin is always allowed. Empty (the default) allows no other origin. `EAX_ALLOWED_ORIGINS` (comma-separated) replaces the list; an entry that is not an origin stops the server at start. Clients that send a token in the `Authorization` header are not checked. See [Cookie-authenticated requests from another origin](/docs/platform/explanation/security-and-part-11/#71a-cookie-authenticated-requests-from-another-origin).

### Live values on `/ws` (`server.ws_batch_ms`, `ws_max_tags`, `ws_max_views`, `ws_max_prefixes`)

| Key | Default | Meaning |
|---|---|---|
| `server.ws_batch_ms` | `100` | The changes of a browser tab's subscribed tags are batched over this window, in milliseconds: 50 to 1000. |
| `server.ws_max_tags` | `50000` | Tags one browser tab (one `/ws` socket) may subscribe: 1 to 500000. Past it, the tags are shown Bad "too many tags on this page". |
| `server.ws_max_views` | `256` | Views (pages, popups, docks, widgets) one tab may subscribe for: 1 to 4096. |
| `server.ws_max_prefixes` | `16` | Prefix entries (`Plant/Line1/*`, every readable tag under a path) one view may hold: 1 to 256. Past it, the prefix is refused. See [Prefixes](/docs/eaxscada/reference/live-data-socket/#prefixes). |

`0` or no key means the default. A value out of range stops the server at start with a message naming the key. See [How live values reach screens](/docs/eaxscada/explanation/live-values/#settings).

### Embedded broker start (`nats.start_timeout`)

At start, the server waits for its embedded NATS server to accept connections. `nats.start_timeout` sets how long: a duration such as `10s`, `30s` or `1m`, at least `1s`, default `10s` (the fixed wait of earlier releases). Raise it on a slow machine or with a large JetStream store (`data\nats`).

When the broker is not ready in time, the server shuts it down first, so that it no longer holds the JetStream store folder, and then stops with the log line `embedded broker failed to start`. Its error names the wait, for example `nats server failed to start within 10s (shut down; nats.start_timeout sets the wait)`. If the broker is still opening its store, the server waits up to 2 more minutes for that to end before it shuts the broker down, and the error says so.

A value that is not a duration, or is under `1s`, is ignored with a `WARN` line (`nats.start_timeout ignored: use a duration of at least 1s, e.g. 30s`), and the default `10s` is kept.

### Historian disk budget (`historian.retention`, `max_size`, `disk`)

Every shipped config file sets a disk budget for new installs: `retention: 90d`, `max_size` `10GB` (Linux archive, appliance, community image) or `20GB` (Windows archive, Pro Docker image, high-availability sample), `warn_free: 15%`, `critical_free: 5%` with a floor of `2GB` or `5GB`, `purge_on_critical` and `pause_on_critical` on, and the logging defaults `1s`, deadband `0`, `10m`. An upgrade leaves an existing file as it is. A file with no `retention` and no `max_size` starts with a warning, `historian has no disk budget`: history is then kept until the disk is critically full. Size `max_size` to the disk: with the columnar store, leave about three times `max_size` free, because the nightly snapshot keeps two copies of the store beside it. What each key does: [Keep the historian within its disk budget](/docs/eaxscada/how-to/keep-historian-within-disk-budget/).

The `historian:` keys after a sub-section the server does not read (for example `parquet_export:` in older sample files) are read. Earlier releases ignored them, so a `retention` or `max_size` written below such a sub-section had no effect.

### Historian copies (`historian.snapshot`, `historian.export`)

| Key | Default | Meaning |
|---|---|---|
| `historian.snapshot.enabled` | `true` (also without the section) | The nightly snapshot of the columnar store, every edition. |
| `historian.snapshot.schedule` | `01:30` | Local time `HH:MM`. |
| `historian.snapshot.dir` | `./data/backup/historian` | The snapshot folder: `historian-.duckdb` and its `.json` record. On another disk it also protects against a lost disk. |
| `historian.snapshot.keep` | `2` | Snapshots kept; the oldest beyond it are deleted once a new one is verified. |
| `historian.export.enabled` | on when not set (Pro, Enterprise, store without encryption at rest) | The daily Parquet export of closed days. An old generated section left exactly as written reads as unset. |
| `historian.export.keep_days` | the historian's retention when not set | Exported days kept in `dir`. |

Both restores run with the server stopped: `eaxscada historian-restore --snapshot <file> [--confirm]` and `eaxscada historian-restore --from-export <dir> [--from <day>] [--to <day>] [--confirm]`; without `--confirm` they are dry runs. [Second copies of the history, and restoring them](/docs/eaxscada/explanation/historian/#4c-second-copies-of-the-history-and-restoring-them)

### Store memory caps (`historian.store`, `production.duckdb`)

Every DuckDB store of the server has a memory cap. A configured value always wins; without one, the store takes its default:

| Key | Default | Meaning |
|---|---|---|
| `historian.store.memory_limit` | 25% of the machine's memory, at least 512 MiB, at most 4 GiB (1 GiB when the memory cannot be read) | The historian store's cap, a size such as `1GB` or `512MB`. The configurations of the Linux archive and the Docker images set `1GB`. An invalid size stops the store from opening; it is never opened without a cap. |
| `historian.store.threads` | one thread per 64 MiB of the cap, at most every core | The historian store's threads. |
| `production.duckdb.memory_limit` | 512 MiB | The cap of `production.duckdb` (OEE and downtime), at least 64 MB. |

The genealogy store's cap is `duckdb_memory_limit` in `data/genealogy/settings.json` (default 1 GiB). The alarms and log console stores take 512 MiB; the audit trail, genealogy states, recipes, security, eaxCollab archive and shift log index stores 256 MiB. A store with no threads setting uses one thread per 64 MiB of its cap, at most every core. Past its cap a store spills to a `.tmp` folder next to its file (encrypted for a store with encryption at rest). The start log has one `DuckDB store memory cap` line per store, with its cap, its threads and where each came from. [Memory caps of the stores](/docs/eaxscada/explanation/historian/#memory-caps-of-the-stores)

### Log file (`logging.file`, `logging.file_enabled`)

The server writes its operational log as JSON lines to one file, rotated at 10 MB with 5 old files kept ([Operational log](/docs/eaxscada/reference/metrics/#operational-log)).

| Key | Environment variable (wins over the file) | Default | Meaning |
|---|---|---|---|
| `logging.file` | `EAX_LOG_FILE` | `logs/eaxScada.log` | The log file. A relative path is under the work directory (`-workdir`). The folder is created. |
| `logging.file_enabled` | `EAX_LOG_FILE_ENABLED` | `true` | `false` writes no log file. The console (the journal under systemd, the container log under Docker), the log table (`/api/logs`) and the syslog export stay. |

- `logging.file_enabled` and `EAX_LOG_FILE_ENABLED` accept `true`/`false`, `1`/`0`, `yes`/`no` and `on`/`off`. Any other value keeps the log file on, and the server logs a warning.
- **A log file that cannot be written stops the server at start.** The server logs "cannot write the log file", the path and the two fixes: set `logging.file` to a writable path, or `logging.file_enabled: false` to log to the console only. It never runs without the log the configuration asks for.
- The Linux packages set `file: "/var/lib/eaxware/eaxscada/logs/eaxScada.log"`. Under systemd a folder outside `/var/lib/eaxware/eaxscada` needs a `ReadWritePaths=` drop-in ([Install on Linux](/docs/platform/how-to/install/)).

### The audit trail folder (`security.audit_data_dir`)

In Starter, Pro and Enterprise the audit trail is the DuckDB database `audit.duckdb` (with its `audit.duckdb.wal`) in this folder, `./data/audit` by default. The Free edition creates nothing there. See [the audit trail on disk](/docs/platform/explanation/security-and-part-11/#25-the-audit-trail-on-disk).

```yaml
security:
  audit_data_dir: "./data/audit"
```

- **Outside the historian folder.** A folder that is `historian.path`, inside it or around it stops a Starter, Pro or Enterprise server at start ("security.audit_data_dir (…) is the historian folder, inside it or around it (…)"). A Free server starts (it records nothing; a trail kept there is not opened), and a licence installed later puts the trail down until the setting is fixed and the server restarted. While the trail records, less than 10 GB free on this folder's volume raises `ALM-SYS-AUDIT-DISK`.
- **On a local disk with 10 GB free or more** (20 GB recommended). A network share, a RAM disk or less than 10 GB free puts the trail down (actions that must be recorded first are refused) until it is fixed; removable media, SD cards, eMMC and implausible sync times are warned. See [Audit trail system requirements](/docs/platform/explanation/security-and-part-11/#25a-audit-trail-system-requirements).
- **A change of folder takes a restart.** The server does not move the file: move `audit.duckdb` and its `.wal` together, with the server stopped.
- **Encryption follows the historian's** (`historian.tde_encryption`): see [Encryption](/docs/platform/explanation/security-and-part-11/#encryption).

### Audit trail memory (`security.audit_memory_records`, `security.audit_memory_bytes`)

**These two keys no longer apply.** The audit trail is a database, read with queries: no records are held in memory for it. A server whose `config.yaml` sets them starts, ignores them and logs "security.audit_memory_records and audit_memory_bytes no longer apply (the audit trail is a database) and are ignored". Remove them from the file.

**A wrong value still stops the server.** A negative number, a value that does not read as a number or a size, and `none`, `unlimited` or `off` for `audit_memory_bytes` are refused at start ("audit ledger settings refused", with the key and the reason), so an old file never behaves differently.

### Switching the AI assistant off

Pro and Enterprise include an AI assistant in the studio and in the eaxPLC IDE. To switch it off on a server, set `assistant.enabled: false` in `config.yaml`, or `EAX_ASSISTANT_ENABLED=false` in the environment (the environment wins). The default is `true`. Accepted values are `true`/`false`, `1`/`0`, `yes`/`no` and `on`/`off`; any other value also switches the assistant off, and the server logs a warning.

When it is switched off:

- its store is not opened: no `data/assistant` directory and no `data/security/assistant.key` are created;
- every `/api/assistant/*` route answers `404` with `{"error":"the AI assistant is disabled on this server","disabled":true}`, for every role and for eaxPLC tokens;
- the studio and the eaxPLC IDE show that the assistant is switched off, with no chat box;
- the server logs once at start-up that the assistant is disabled.

The MCP gateway is a separate feature and is not affected.

When the assistant is on, `GET /api/assistant/status` reports `configured: true` only when at least one enabled AI provider exists, and `can_chat: true` only when the user's role may chat (Shift_Operator and above) and the project named by `?project=` exists and allows at least one enabled provider. Without `?project=`, `can_chat` is true when at least one project allows an enabled provider.

### What the studio opens first

```yaml
studio:
  default_screen: "plant_overview"   # optional
  live_preview_default: false
```

- `default_screen`: the screen the Designer opens when the browser has no last-opened screen, and the screen a plain `/runtime` (no `project`, `page` or `screen` in the address) opens. Empty: the project's startup page.
- `live_preview_default`: `true` opens the Designer with Live Preview on (bound values follow the live tags). Per visit, `?live=1` or `?live=0` in the studio address wins; `?screen=<id>` opens that screen.

A fresh data folder starts clean: no screen, folder, dashboard, recipe, example alarm, driver channel or simulated tag is created. Starter content is added on request from the studio (Displays > New > From template...), never at start-up.

---

## 3. Network ports

**Diagram: The network ports of an eaxScada server** (network topology)

An eaxScada server listens on two ports, 8080 for browsers and MCP clients and 4222 for NATS clients, both on 127.0.0.1 unless the configuration says otherwise. It opens every other connection itself: to eaxPLC on 8085 and, through its driver channels, to the plant devices on the port each channel names.

**Parts**

- **Plant network** (network)
- **Browsers** (person or role): and MCP clients
- **NATS clients** (service or process): other services
- **eaxPLC** (product): REST API
- **eaxScada server** (product): listens on 127.0.0.1 by default  NATS monitoring 127.0.0.1:8222  NATS cluster 4248, off by default
- **Modbus TCP devices** (device or controller, inside Plant network): PLCs, drives, meters
- **Siemens S7 PLCs** (device or controller, inside Plant network): S7-300/400/1200/1500 (ISO-on-TCP)
- **EtherNet/IP devices** (device or controller, inside Plant network): Logix and Micro800 PLCs, Omron NJ/NX, drives, I/O
- **OPC UA servers** (service or process, inside Plant network)
- **MQTT broker** (service or process, inside Plant network)

**Connections**

- **Browsers ↔ eaxScada server** (data or telemetry): 8080. Browsers and MCP clients open the connection to the web port: the studio, the operator runtime, the REST APIs, the WebSocket /ws and MCP.
- **NATS clients ↔ eaxScada server** (data or telemetry): 4222. NATS clients open the connection to the embedded NATS server.
- **eaxScada server ↔ eaxPLC** (data or telemetry): 8085. eaxScada opens the connection to eaxPLC, at the address of its -plc-url flag (default http://localhost:8085).
- **eaxScada server ↔ Modbus TCP devices** (data or telemetry): 502. eaxScada opens the connection; the device listens.
- **eaxScada server ↔ Siemens S7 PLCs** (data or telemetry): 102. Siemens S7-300/400/1200/1500 controllers over ISO-on-TCP, port 102 by default.
- **eaxScada server ↔ EtherNet/IP devices** (data or telemetry): 44818. One EtherNet/IP channel kind, port 44818 by default: Rockwell / Allen-Bradley ControlLogix, CompactLogix and Micro800 controllers by tag name, MicroLogix, SLC 500 and PLC-5 over PCCC, Omron NJ/NX controllers, and EtherNet/IP devices such as drives and I/O adapters.
- **eaxScada server ↔ OPC UA servers** (data or telemetry): 4840
- **eaxScada server ↔ MQTT broker** (data or telemetry): 1883

The plant devices never connect to eaxScada: only the web and NATS ports need to be open towards it. The device ports are the drivers' defaults; each channel can set its own.

| Port | Protocol | Subsystem | Direction | Purpose |
|---|---|---|---|---|
| **8080** | TCP | Web server and HMI | Inbound | Dev Studio, operator runtime, REST APIs, WebSockets (`/ws`) and MCP JSON-RPC (`/api/mcp/rpc`). On `127.0.0.1` unless `server.host` says otherwise. |
| **4222** | TCP | Embedded NATS UNS | Inbound | NATS protocol, JetStream streaming and Key-Value operations. On `127.0.0.1` unless `nats.host` says otherwise. |
| **8222** | TCP | NATS monitoring | Inbound | Monitoring endpoint of the embedded NATS server, on `127.0.0.1` (`nats.http_host`, `nats.http_port`). |
| **4248** | TCP | NATS cluster | Inbound/outbound | Only when `cluster.enabled` is on (off by default). |
| **8085** | TCP | eaxPLC | Outbound | eaxScada connects to the REST API and flight recorder of the companion eaxPLC runtime, at the address of `-plc-url` (default `http://localhost:8085`). |
| **502** | TCP | Modbus TCP | Outbound | Modbus to PLCs, drives and power meters. The default of a channel; to reach the eaxPLC Modbus TCP server, set the channel's port to 5020. |
| **4001** | TCP | Modbus RTU over TCP | Outbound | Modbus RTU frames over a TCP connection (`MODBUS_RTU_TCP` channels). |
| **102** | TCP | S7 ISO-on-TCP | Outbound | RFC 1006 COTP connection to S7-300, S7-400, S7-1200 and S7-1500 PLCs. |
| **44818** | TCP | EtherNet/IP (CIP) | Outbound | EtherNet/IP (CIP) controllers with symbolic tag access. |
| **9600** | TCP/UDP | FINS | Outbound | FINS controllers, over FINS/UDP (the default) or FINS/TCP. |
| **4840** | TCP | OPC UA client | Outbound | Binary connection to OPC UA servers (default endpoint `opc.tcp://127.0.0.1:4840`). |
| **1883** | TCP | MQTT client | Outbound | MQTT JSON and Sparkplug B telemetry (default broker `tcp://127.0.0.1:1883`). A broker on another port is set in the channel. |

The outbound ports are the defaults of a new channel; each channel can set its own.

### When the web port is busy

eaxScada does **not** move to another port when its web port is taken. A service refuses to start, with a fatal error naming the port, so that a second instance can never silently take over a different port. Stop the other process or change `server.port`.

Only a developer run with `EAX_DEV_MODE` set takes the next free port, and it logs a warning when it does.

---

## 4. Edition and licence

The edition a server runs is the edition of its verified licence. Without a licence, or with one that does not verify, it runs the **Free** edition. Nothing in `config.yaml`, the environment or the command line raises the edition. The `-tier` flag can only lower it, for testing.

The licence is the file `data/licence/licence.json` under the work directory, or the file named by `licence.file`. It is verified offline, at every start and once a minute, against the public keys built into eaxScada. A server never needs to reach the internet to check it. To install one, see [Activate a licence](/docs/eaxscada/how-to/activate-licence/).

| State | What the server does |
|---|---|
| No licence | Free edition. |
| Valid licence | The licence's edition: Starter, Pro or Enterprise. |
| Changed, damaged or signed with an unknown key | Free edition. The server logs the reason, and the studio shows it in the licence dialog. |
| Expired | Free edition from the moment it expires. A running runtime starts a 60-minute Free session then. |
| Built after the licence's support date | Free edition, unless the release is a security update (x.y.z, z of 1 or more) of a version line first released on or before the support date and built on or before the licence's security date. A licence activates every release it covers for as long as you run it. See [Support and security dates](/docs/eaxscada/how-to/activate-licence/#support-and-security-dates). |

The build decides which capabilities exist at all. The **full** build has the columnar historian, the AI assistant and single sign-on. The **standard** build is pure Go and has none of the three. The release server is the full build for every edition, so Starter stores its history in the columnar historian too; the features built on it (part and lot genealogy, the Parquet analytics export) are Pro and Enterprise. A Pro licence on a standard build runs as Pro without them, and the studio says so.

### The Free edition's runtime sessions

In the Free edition every feature works for evaluation and non-production use, except high availability and 3D design. The runtime runs in **60-minute sessions**. The session length cannot be configured.

- **The runtime** is driver polling and writes, scripts, recipes and batches, alarm evaluation, historian logging, PLC deploys from eaxScada, and integration and MCP control commands. It runs only during a session.
- **Always available**, in and out of a session: the studio and designer, configuration, the values and history already recorded, and the licence dialog.
- **Warnings** come at 50 and 55 minutes, as a banner in the studio and the operator runtime and as a log line.
- **At 60 minutes the runtime stops in-process.** The web server stays up and nobody is signed out.

When the runtime stops:

1. Writes, recipe downloads, batch steps and PLC deploys already under way complete first. New ones are refused, so a recipe is never half applied.
2. Driver polling stops and the channels disconnect, the same as when an engineer disables a channel. Running batches go to HOLD.
3. Every tag shows Bad quality with the reason `runtime stopped (Free edition session ended)`. The last value stays on screen.
4. Alarm evaluation stops. Standing alarms keep their state and are marked suppressed, so the stop raises no alarm and clears none.
5. The stop is recorded in the audit trail.

The PLCs keep running; eaxScada stopped supervising. eaxScada does not run control loops, and it sends nothing to any device when it stops.

**Start new runtime session**, in the banner, starts the next session. Any signed-in user with the Shift_Operator role or a higher role can press it, and it is recorded in the audit trail. The API is `POST /api/runtime/session/start`. A running session cannot be extended, and the 60 minutes are timed on the server's monotonic clock, so neither a configuration change nor a change of the system clock resets them. The server process itself can run indefinitely. There is no limit on the number of sessions.

### High availability

High availability needs an Enterprise licence that covers two servers. In any other edition, a configured cluster (`cluster.enabled`, cluster routes, `-ha-role`, `HA_ROLE`) is ignored: the server logs why and runs as a single node. A witness (`-witness`) refuses to start.

### Status and metrics

`GET /api/system/info` returns the edition (`edition`), the licence state (`licence`), the runtime and its session (`runtime.running`, `runtime.session.remaining_s`), and which features the server may use (`features`). `GET /api/runtime/session` returns the runtime part to any signed-in user. `/metrics` has:

| Metric | Meaning |
|---|---|
| `eaxscada_edition_info{edition,licence,flavour}` | Always 1. The labels carry the edition in force, the licence state and the build flavour. |
| `eaxscada_runtime_running` | 1 while the runtime runs, 0 while it is stopped. |
| `eaxscada_free_session_seconds_remaining` | Free edition only: seconds left in the session, 0 once it has ended. |
