Environment variables
Environment variables allows you to inject configuration into the applications running in the edge
Environment variables are a standard way to configure your applications. Typically, you can set them directly on the application:
Inheriting From Device
Synpse provides a mechanism to inject device environment variables to your applications.
You can either manually specify custom environment variables for each device or you can also specify them on the registration token during the provisioning.
Setting environment variables on a device (web user)
To set an environment variable for a device:
Open the device details
Click on the "New env var" button
Enter environment variable name and value
Now, any application that is deployed on that device, will get the environment variable:
You can have multiple environment variables on each device.
You can use device environment variables to specify some customer related data so your applications can display tailored information based on where they get deployed.
Synpse Provided Environment Variables
Synpse provides certain metadata for the applications as environment variables. It's up to the application to use these environment variables or ignore them.
Environment Variable | Description | Example Value |
SYNPSE_DEVICE_NAME | Device name in Synpse | powerplant-42 |
SYNPSE_DEVICE_IP | Device IP address | 192.168.1.111 |
SYNPSE_DEVICE_HOSTNAME | Device hostname | rasp4-node |
SYNPSE_DEVICE_ARCH | CPU architecture | arm |
SYNPSE_PROJECT_ID | Project ID | prj_1r1pqWAG... |
SYNPSE_NAMESPACE_ID | Namespace ID | nms_1r1pqW4d... |
SYNPSE_APPLICATION_ID | Application ID | app_1a812qwe... |
These environment variables are always available for applications running under Synpse. No additional settings are required.
Substitution
Synpse provides the ability to expand, or substitute, application and device metadata to facilitate dynamic application configurations.
Example Device Substitution
Let's say you have set an environment variable on the device called:
Now, you can use that environment variable to create something else, for example a URL on which the device will be accessible by users (assuming you have configured domain, etc.):
And your application will then see an environment variable which equals
String Operations
Synpse provides partial emulation for bash string operations. This can be used to manipulate string values prior to substitution.
Example variable substitution with substring:
Synpse emulates the below string operations:
Synpse makes a best-effort to emulate these operations however we do not promise perfect emulation.
Escaping
If you do not want the system to evaluate an expression it must be escaped:
Last updated