RDKShell Configuration
The complexity of the configuration of RDKShell is increasing. Perhaps the time has come to consider a configuration file. This page suggests a possible format for one and how it would work alongside the current environment variables approach.
Environment Variables
Currently RDKShell is configured by a series of environment variables.
Name | Type | Default | Description |
---|---|---|---|
RDKSHELL_CRITICALLY_LOW_MEMORY_THRESHOLD | integer | The number of Mb of free memory below which to send a critical notification to clients. | |
RDKSHELL_ENABLE_IPC | Boolean (“0” or “1”) | false | |
RDKSHELL_ENABLE_WS_IPC | Boolean (“0” or “1”) | false | |
RDKSHELL_EASTER_EGG_FILE | file path | ||
RDKSHELL_EXTENDED_INPUT_ENABLED | Boolean | false | Whether the Westeros “rdkshell_extended_input” plugin is loaded. |
RDKSHELL_FRAMERATE | integer | Desired framerate. | |
RDKSHELL_INPUT_DEVICES_CONFIG | file path | A JSON file containing input device configuration. | |
RDKSHELL_KEY_INITIAL_DELAY | integer | 500 | Initial delay before repeating key in milliseconds. |
RDKSHELL_KEY_REPEAT_INTERVAL | integer | 100 | Interval at which key repeats. |
RDKSHELL_KEYMAP_FILE | file path | ||
RDKSHELL_LOG_LEVEL | “debug”, “info”, “warn”, “error”, “fatal” | Set the logging level to use. | |
RDKSHELL_LOW_MEMORY_THRESHOLD | integer | The number of Mb of free memory below which to send a notification to clients. | |
RDKSHELL_SERVER_ADDRESS | network address | “localhost” | |
RDKSHELL_SERVER_PORT | integer | 9996 |
Proposed Configuration File
Since JSON has been used for other configuration files in RDKShell then I would suggest JSON again.
Currently all fields will be optional since RDKShell does not require any environment variables to be set.
The top-level JSON object has fields:
Field | Description |
---|---|
logging | Related to logging |
resource_usage | Related to the resource usage of RDKShell |
input | Related to inputs handled by RDKShell |
comms | Related to communication with RDKShell |
where the values associated with all fields are JSON objects.
Logging
The logging JSON object would initially only have the following field:
Field | Type | Description | Environment Variable |
---|---|---|---|
level | “debug”, “info”, “warn”, “error”, “fatal” | The level of logging to use. | RDKSHELL_LOG_LEVEL |
Resource Usage
The resource usage JSON object would initially have a single field “memory” with an associated JSON object. This JSON object would have the following fields:
Field | Type | Description | Environment Variable |
---|---|---|---|
critical_low_threshold | integer | Send client critical notifications if this threshold is breached. | RDKSHELL_CRITICALLY_LOW_MEMORY_THRESHOLD |
low_threshold | integer | Send clients notifications if this threshold is breached. | RDKSHELL_LOW_MEMORY_THRESHOLD |
So the path would be ‘config["resource_usage"]["memory"]["low_threshold"]
‘.
Input
The input JSON object has the following fields.
Field | Type | Description | Environment Variable |
---|---|---|---|
key | object | Configuration related to keys. | |
device_config | file path | A file containing configuration for the device. | RDKSHELL_INPUT_DEVICES_CONFIG |
easter_egg_file | file path | RDKSHELL_EASTER_EGG_FILE | |
plugin | filename | An external Westeros plugin to support custom input events. | ~ RDKSHELL_EXTENDED_INPUT_ENABLED |
where the key JSON object has the following fields.
Field | Type | Description | Environment Variable |
---|---|---|---|
initial_delay | integer | Initial delay before repeating key in milliseconds. | RDKSHELL_KEY_INITIAL_DELAY |
repeat interval | integer | Interval at which key repeats in milliseconds. | RDKSHELL_KEY_REPEAT_INTERVAL |
map_file | file path | RDKSHELL_KEYMAP_FILE |
Comms
The communications JSON object would have the following fields:
Field | Type | Description | Environment Variable |
---|---|---|---|
enable_ipc | boolean | RDKSHELL_ENABLE_IPC | |
enable_ws_ipc | boolean | RDKSHELL_ENABLE_WS_IPC | |
server_address | network address | RDKSHELL_SERVER_ADDRESS | |
server_port | integer | RDKSHELL_SERVER_PORT |
Example
An example configuration file could be:
|
Location
A default location for the configuration file could be a build-time parameter with default locations per OS e.g. “/etc/rdkshell/config.json” for UNIX flavour. Absence of the configuration file implies defaults are used.
Precedence: Environment Variables vs Configuration File
To ensure backwards compatibility supporting both seems sensible. A standard approach is for environment variables to have precedence over the configuration file. Having the configuration printed to log when RDKShell starts will make it easier to see the configuration.