If you are running multiple instances of the same application, either on a single VM/server/container, or across multiple hosts, it is often useful to assign each instance a unique ID.
You can provide an instance ID, to each instance of your application via a command line argument which is then made available to your application components if they need it.
Providing an ID via the command line
Start your application with the
-i argument. E.g.:
myapp -i myid
You will see a message similar to:
29/Oct/2019:11:01:08 Z INFO [grncInit] Instance ID: myid
Generating an instance ID
If you set the flag
-u when starting your application, Granitic will generate a V4 UUID and use that as an instance
Accessing the ID from your components
If your component implements instance.Receiver
(e.g. implements the method
RegisterInstanceID(*instance.Identifier)), the instance ID will be passed in to that
method before the container starts your components.
The instance ID will also be injected into your application’s merged configuration and can be found at
the config path
Next: System configuration
Prev: Remote configuration