Enterprise

# Configure a standalone Driver

> Set the connection, task, and integration parameters of a standalone Driver with its state file, a configuration file, environment variables, or flags.

A standalone Driver reads its parameters from five sources. A source higher in the list overrides the sources below it:

1. Command line flags. See the [CLI reference](https://docs.synnaxlabs.com/reference/enterprise/driver/cli-reference).
2. [Environment variables](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#environment-variables).
3. A [configuration file](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#configuration-file).
4. The [state file](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#state-file), which `synnax-driver login` writes.
5. The defaults.

The parameter flags and the configuration file apply only to `synnax-driver start --standalone`. The Linux and NI Linux Real-Time service always starts with the same command. To configure the service, use `login` and the [environment file](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#environment-file). Run `login` once, also when the environment file holds the connection: `login` creates the folder of the state file, and the service cannot.

## State file

The state file holds the connection parameters and the API key that `login` saves. Only its owner can read it.

| Operating system   | Path                                                               |
| ------------------ | ------------------------------------------------------------------ |
| Linux, NI Linux RT | `/var/lib/synnax-driver/persisted-state.json`                      |
| Windows            | `%LOCALAPPDATA%\synnax-driver\persisted-state.json`                |
| macOS              | `~/Library/Application Support/synnax-driver/persisted-state.json` |

The `--state-file` flag of `start --standalone`, `login`, and `clear` sets a different path. The service always uses the default path.

To remove the saved login, run `synnax-driver clear`. Run `login` again before the next start.

## Environment variables

The Driver reads each parameter from a variable named `SYNNAX_DRIVER_` and the key in upper case. The integrations have no variable.

```bash
SYNNAX_DRIVER_HOST=10.0.0.45
SYNNAX_DRIVER_PORT=9090
SYNNAX_DRIVER_API_KEY=syk_...
SYNNAX_DRIVER_SECURE=false
SYNNAX_DRIVER_CORRECT_SKEW=true
SYNNAX_DRIVER_OP_TIMEOUT=60
SYNNAX_DRIVER_POLL_INTERVAL=1
SYNNAX_DRIVER_SHUTDOWN_TIMEOUT=30
SYNNAX_DRIVER_WORKER_COUNT=4
```

To learn what each parameter does, see [Parameters](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#parameters).

### Environment file

On Linux and NI Linux Real-Time, the service and `login` read `/etc/synnax/driver.env`. Write one `KEY=value` on each line, with no `export`. `login` uses the file only for variables such as `GRPC_DEFAULT_SSL_ROOTS_FILE_PATH`. It does not read the `SYNNAX_DRIVER_` variables.

`install` creates the file. Only root can read it, so edit it and run `login` as root: with `sudo` on Linux, and as `admin` on NI Linux Real-Time. Restart the service after you edit the file.

`start --standalone` does not read the file. For a Driver in a terminal, export the variables in the shell:

```bash
export SYNNAX_DRIVER_WORKER_COUNT=8
synnax-driver start --standalone
```

## Configuration file

Give a JSON file to `start --standalone` with the `--config` flag. Each key is optional. The file cannot hold comments.

```json
{
  "connection": {
    "host": "10.0.0.45",
    "port": 9090,
    "api_key": "syk_...",
    "secure": false
  },
  "timing": {
    "correct_skew": true
  },
  "manager": {
    "op_timeout": 60,
    "poll_interval": 1,
    "shutdown_timeout": 30,
    "worker_count": 4
  },
  "integrations": ["arc", "ethercat", "http", "labjack", "modbus", "ni", "opc"]
}
```

The `integrations` list replaces the default list.

A Driver with no API key logs in once with `username` and `password`, creates a rack and its API key, and saves the key in the state file. An upgraded Driver that saved a rack before does this at its first start and keeps its rack. If that user cannot create racks, the Driver keeps logging in with the password and tries again at each start. Once a key is saved, the Driver ignores a username and password and logs a warning.

## Parameters

* [`host`](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#host)`= localhost`

  The host of the Core.

* [`port`](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#port)`= 9090`

  The port of the Core.

* [`api_key`](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#api_key)`= ""`

  The API key of the Driver’s rack. The Driver logs in as that rack.

* [`username`](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#username)`= synnax`

  The username to log in with once, to create a rack and its API key. Ignored when an API key is set.

* [`password`](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#password)`= seldon`

  The password to log in with once, to create a rack and its API key. Ignored when an API key is set.

* [`secure`](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#secure)`= false`

  Connect to the Core over TLS.

* [`correct_skew`](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#correct_skew)`= true`

  Keep the timestamps of hardware-timed NI and LabJack reads in step with the clock of the computer.

* [`op_timeout`](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#op_timeout)`= 60`

  The number of seconds after which a task operation that has not finished, such as a start, gives the task the error `operation timed out`.

* [`poll_interval`](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#poll_interval)`= 1`

  The number of seconds between two checks for task operations that have not finished.

* [`shutdown_timeout`](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#shutdown_timeout)`= 30`

  The number of seconds that the Driver waits for task operations when it stops.

* [`worker_count`](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#worker_count)`= 4`

  The number of threads that run task operations. Use a value from 1 to 64.

* [`integrations`](https://docs.synnaxlabs.com/reference/enterprise/driver/configuration#integrations)`= all`

  The device integrations to run: `arc`, `ethercat`, `http`, `labjack`, `modbus`, `ni`, and `opc`. NI Linux RT has no `modbus`.

For a boolean environment variable, use `true` or `false`.
