Skip to content

Environment Variables

Allon Guralnek edited this page Aug 30, 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 - Specifies the location of the environmentVariables.json file (see below for details). Default value: D:\Gigya\EnvironmentVariables.json
  • GIGYA_CONFIG_ROOT - 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 - Specifies the location of the loadPaths.json which lists the folders where the configuration is located. Default value: %GIGYA_CONFIG_ROOT%\loadPaths.json
  • GIGYA_SERVICE_INSTANCE_NAME - Specifies the instance name use to differentiate separate clusters of the same service and same version. The default value is DefaultInstance, overridden by this environment variable if specified, which is then overridden by a command line argument --InstanceName.
  • DC - [Required] Specifies the datacenter where the service is deployed. Usually this is a physical location (like AWS availability zones).
  • ENV - [Required] 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.
  • CONSUL Specifies the address (hostname and port) of the Consul server. If not specified, it assumes there's a local Consul agent and defaults to 127.0.0.1:8500.

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.