Setting the Consul Connection Parameters
You set the values for app properties that you want to override by creating a Key/Value pair for each property in Consul. You can create a standalone property or a hierarchy that groups multiple related properties.
<key_prefix>/<key_name>
where
<key_prefix>
is a meaningful string or hierarchy that serves as a path to the key in Consul and
<key_name>
is the name of the app property whose value you want to override. dev/Timer/Message
and
test/Timer/Message
,
dev/Timer
and
test/Timer
are the
<key_prefix>
which could stand for the dev and test environments and
Message
is the key name. During runtime, you provide the
<key_prefix>
value that tells your app the location in Consul from where to access the property values.
Message
, is looked up by your app as either
Message
or
<key_prefix>/Message
in Consul. An app property within a hierarchy such as
x.y.z
is looked up as
x/y/z
or
<key_prefix>/x/y/z
in Consul. Note that the dot in the hierarchy is represented by a forward slash (/) in Consul.
After you have configured the app properties in Consul, you need to set the environment variable,
FLOGO_APP_PROPS_CONSUL
, with the Consul connection parameters for your app to connect to the Consul. When you set the environment variable, it triggers the app to run, which connects to the Consul using the Consul connection parameters you provided and pulls the app property values from the
key_prefix
location you set by matching the app property name with the
key_name
. Hence, the Key names must be identical to the app property names defined in the
Application Properties dialog in
Flogo.
You can set the
FLOGO_APP_PROPS_CONSUL
environment variable by placing the properties in a file and using the file as input to the
FLOGO_APP_PROPS_CONSUL
environment variable.
Setting the Consul Parameter Values Using a File
To set the parameter values in a file, create a
.json
file, for example,
consul_config.json
containing the parameter values in key/value pairs. Here is an example:
{ "server_address": "http://127.0.0.1:32819", "key_prefix": "/dev/<APPNAME>/", "acl_token": "SECRET:b0UaK3bTyD9wN+ZJkmlKRmojhAv+" }
Place the
consul_config.json
file in the same directory that contains your app binary.
Run the following from the location where your app binary resides to set the
FLOGO_APP_PROPS_CONSUL
environment variable. For example, to use the
consul_config.json
file from the example above, run:
FLOGO_APP_PROPS_CONSUL=consul_config.json ./<app_binary_name>
The command extracts the Consul server connection parameters from the file and connects to the Consul to pull the app properties values from the Consul and runs your app with those values.
Consul properties can also be run using Docker by passing the same arguments for the docker image of a binary app.