Skip to content

Environment Variables

Allon Guralnek edited this page Jun 22, 2017 · 6 revisions

Microdot uses environment variables as a way to determine various aspects of how the service runs. There are a few important environment variables that are used by Microdot:

  • GIGYA_ENVVARS_FILE - This specifies the location of the environmentVariables.json file (see below for details). Default value: D:\Gigya\EnvironmentVariables.json
  • GIGYA_CONFIG_ROOT - This specifies the root folder of the configuration. All folders specified in loadPaths.json must be under this folder, otherwise they won't be monitored for changes. Default value: D:\Gigya\Config
  • GIGYA_CONFIG_PATHS_FILE - This specifies the location of the loadPaths.json which lists the folders where the configuration is located. Default value: %GIGYA_CONFIG_ROOT%\loadPaths.json
  • DC - [Required] This specifies the datacenter where the service is deployed. Usually this is a physical location (like AWS availability zones).
  • ENV - [Required] This specifies the deployment environment within the datacenter. It is typical to have several environments within a data center for several stages of deployment. For example: private staging, public staging, canary, production.

Environment Variable File

A limitation of environment variables (at least in Windows) is that they are copied to the process when it starts and child processes only see the parent's environment variables. So if you have Visual Studio running and then change an environment variable, you won't see the new value when debugging your service because it copies its environment variables from the parent process (Visual Studio) which has old values stored. This can become quite an annoyance during development on a local machine, which is why Microdot allows loading environment variables from a file.

When the application is loaded, it reads a JSON file which defines all environment variables that should be set at the process level, but without replacing existing environment variables already defined. This is typically used only on development machines.

The file consists of a JSON object that has properties with string values, where each property name is the environment variable name and each key is the its value. GIGYA_ENVVARS_FILE cannot be specified in the file.

Example environmentVariables.json file:

{
    "DC": "eu",
    "ENV": "staging",
    "GIGYA_CONFIG_ROOT": "C:\\microdot\\config\\"
}

After editing this file, you can start a debugging session and the changes will take effect.