Skip to main content

System definition

The system-definition file genesis-system-definition.kts is the main configuration file for your application, controlling how the application behaves at runtime.

The file is found in the server cfg directory.

This section explains all the different items that can be contained in the file.

Here is an example of a genesis-system-definition.kts file for an application named 'position':

package genesis.cfg

systemDefinition {
global {
item(name = "DEPLOYED_PRODUCT", value = "position")
item(name = "MqLayer", value = "ZeroMQ")
item(name = "DbLayer", value = "SQL")
item(name = "DictionarySource", value = "DB")
item(name = "AliasSource", value = "DB")
item(name = "MetricsEnabled", value = "false")

item(name = "ZeroMQProxyInboundPort", value = "5001")
item(name = "ZeroMQProxyOutboundPort", value = "5000")

item(name = "DbHost", value = "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=Password5432")
item(name = "DbMode", value = "POSTGRESQL")
item(name = "GenesisNetProtocol", value = "V2")
item(name = "ResourcePollerTimeout", value = "5")
item(name = "ReqRepTimeout", value = "60")
item(name = "MetadataChronicleMapAverageKeySizeBytes", value = "128")
item(name = "MetadataChronicleMapAverageValueSizeBytes", value = "1024")
item(name = "MetadataChronicleMapEntriesCount", value = "512")
item(name = "DaemonServerPort", value = "4568")
item(
name = "JVM_OPTIONS",
value = "-XX:MaxHeapFreeRatio=70 -XX:MinHeapFreeRatio=30 -XX:+UseG1GC -XX:+UseStringDeduplication -XX:OnOutOfMemoryError=\"handleOutOfMemoryError.sh %p\""
)
}

systems {
system(name = "DEV") {
hosts {
host(name = "genesis-serv")
}

item(name = "DbNamespace", value = "genesis")
item(name = "ClusterPort", value = "6000")
item(name = "Location", value = "LO")
item(name = "LogFramework", value = "LOG4J2")
item(name = "LogFrameworkConfig", value = "log4j2-default.xml")
}
}
}

Applying a change​

Processes read the system definition when they start, so a running process doesn't pick up a change. After you change an item, run genesisInstall, then restart the processes that use the item. genesisInstall regenerates the copy of the system definition that startProcess reads, for example for JVM_OPTIONS and for the process overrides described below.

Global, System and Host levels​

As you can see from the example, you can define items at global, system and host level.

  • Global: These properties will be available to all systems.

  • System: These properties contain information about a particular system and can have a free text field. Each system is associated with a host or hosts. The content should specify the type of environment the system is running in. Local values can be specified in this block. These values override the global values.

  • Host: In this section you can define the properties of the host or hosts (if running in a cluster environment). A Host block can only exist under the system section, as you can see in the above example. The host name defines what environment you are running in. By default, only one host will be used and you must set its value to the hostname of the current machine.

This hierarchy enables you to specify multiple environments with a single unchanged built application. You can specify separate DEV, UAT and PROD environments and overrides to system configuration for each, for example.

note

System block resolution: The system blocks are resolved in sequence from top to bottom by reading the hosts information within each system block. The genesis-system-definition.kts file is used to determine the order of system declarations.

If other system blocks are defined in a different order in other system-definition.kts files that are not genesis-system-definition.kts, it won't affect the resolution order of genesis-system-definition.kts.

Items defined​

MqLayer: This setting defines the type of Message queue technology. You can choose between ZeroMQ and Aeron message queues.

DbLayer: The database layer. Set it to SQL for PostgreSQL, Oracle, MSSQL or H2, and then set the DbHost item to the JDBC connection string for your database. FDB and FDB2 are also accepted, but FoundationDB is deprecated in 10.0 and is planned for removal in 11.0.0.

DbHost: Contains information about the hostname/JDBC connection string pointing to local database. For example:

item(name = "DbHost", value = "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=Password5432")

See our pages on database technology for more information on how to configure a specific database.

Database username and password encryption

You may want to encrypt usernames, passwords and other key configuration values such as database credentials.

To encrypt a username and password, run the encryptUserPassWithKey script. It asks for a username, a password and a key, and prints the encrypted username and password.

The key must be a 32-character alphanumeric string. Keep it secret, and set the same value in the GenesisKey system definition item. Once GenesisKey is set, every encrypted value in the system definition must be encrypted with that key.

warning

The older encryptUserPass script is deprecated and will be removed in 11.0.0. It is part of the deprecated genesis-genesistodb module, and it encrypts with a fixed built-in key rather than one you supply. Use encryptUserPassWithKey instead.

Example usage:

global.genesis.config.utils.PasswordEncryptor
Enter userName
my.user
Enter password
password123
Enter key
ABCDEFGHIJKLMNOPQRSTUVWXYZ123456
userName: ab8b6921e904a1dbf058041ae176f27323ed2f835c0a5276b307ef539f6ef6d9
password: a8a4d770afe25446434c2a13fa614be74274220c10a5b8346cf5629807374d2a

Copy the output userName and password values and keep these safe.

Given the sensitive nature of these field values, it is advisable NOT to put the raw values into the system definition file, and instead to use environment variables to override these system definition items or a credentials manager such as Hashicorp Vault to avoid adding sensitive data into your code repository.

DictionarySource: This setting defines where you want to store the dictionary schema. You can choose between DB dictionary source and FILE dictionary source using this setting. Accepted values DB and FILE. DB dictionary source is preferred, because if you are running a cluster, all nodes will refer to the same dictionary. FILE dictionary source has the problem of being only available on each node.

DbSqlMaxPoolSize: This setting limits the maximum number of connections to the database.

DbMaxRetryBeforeExit: This setting defines the maximum number of database connection retry attempts before the Genesis process terminates. It prevents the application from retrying forever when the database is unavailable.

Default value: -1 (infinite retries). When set to -1, the application will retry indefinitely.

Configuration:

item(name = "DbMaxRetryBeforeExit", value = "5")

The retry mechanism uses exponential backoff with the following pattern:

  • 1s → 2s → 4s → 8s → … (capped at 64s max)

SqlViewsEnabled: Controls how views are read on SQL databases (PostgreSQL, SQL Server, Oracle, H2 and HSQL). When true, a view that can be expressed in SQL is read with a single SQL join query, and Data Server queries with backwards joins on such a view use the SQL join cache generated for it. Default value is true from 10.0; earlier versions default to false. Set it to false to read views as in earlier versions. A view that has a dynamic join can't be expressed as a single SQL join query, so it is always read as if this item were false. It has no effect on other database layers, such as FoundationDB. See getByCriteria for how this affects criteria and sorting on views.

MemoryEfficientBackwardJoinCache: When true, the cache that tracks backwards joins keeps its links in compact, primitive storage, which uses much less heap for views with many rows, at the cost of slightly slower lookups and startup. It applies to every subscription to a view with backwards joins in the process: Data Server queries, consolidators, dynamic rules, and bulkSubscribe or rangeSubscribe calls with backwardJoins = true. Default value is true from 10.1; earlier versions default to false. Set it to false to use the cache from earlier versions.

BackwardJoinSharedState: When true and MemoryEfficientBackwardJoinCache is on, backwards joins on the same table and fields share their cached join state across all the subscriptions in a process, instead of each subscription keeping a copy. Default value is true from 10.1; earlier versions default to false. Set it to false to give each subscription its own copy.

BackwardJoinChannelUpdates: Controls how backwards joins receive updates to the tables they join. Accepted values are false, true and SHARED. With false (the default), each backwards join subscribes to its table like any other database subscription. With true, each backwards join receives its updates through its own channel from the update queue, without a thread of its own. With SHARED, the backwards joins of a process on the same table share one update queue listener and parse each update once. It only takes effect when DbSubscriptionMode is BLOCKING. Set it to true or SHARED in processes with many backwards joins to cut the threads and work each update costs.

DbSubscriptionMode: Controls how a process delivers database updates to its subscriptions, such as Data Server queries and backwards joins. Accepted values are BLOCKING and SHARED_FLOW. With BLOCKING (the default), each subscription registers its own update queue listener and reads its updates on a thread of its own. With SHARED_FLOW, subscriptions to the same table with the same settings share one listener, and updates are delivered on a fixed pool with one thread per processor. Set it to SHARED_FLOW in processes with many subscriptions to the same tables to reduce threads.

ListenerBufferCapacity: When DbSubscriptionMode is SHARED_FLOW, the number of updates each shared listener holds for subscribers that have not read them yet. Default value is 1048576. When the buffer is full, new updates for that table wait until the slowest subscriber makes room.

ListenerBufferWarningDuration: When DbSubscriptionMode is SHARED_FLOW, how long, in milliseconds, an update can wait for room in a full listener buffer before the process logs that the buffer has overflowed. Default value is 10000. The update is still delivered once there is room.

AliasSource: This setting defines where you want to store dictionary alias schema. The alias schema maps aliases to fields and to tables, and it is updated every time we change the data schema. You can choose between DB alias source and FILE alias source using this setting. Accepted values DB and FILE. DB alias source is recommended, because if you are running a cluster, all nodes will refer to the same alias dictionary. FILE alias source has the problem of being only available on each node.

GenesisNetProtocol: This is the Genesis network protocol. It is used by the platform only. Do not change this value.

MetricsEnabled: Default value is false. For more information, go to the page on metrics.

MetricsJvmEnabled: When metrics are enabled, controls whether JVM memory, garbage collection and thread metrics are collected. They are on by default; set this item to false to turn them off. For more information, go to the page on metrics.

MetricsCriteriaOverlapEnabled: When true, each Data Server query reports how much its subscribers' criteria overlap. Default value is false. It only takes effect when MetricsEnabled is true. For more information, go to the page on metrics.

ZeroMQProxyInboundPort and ZeroMQProxyOutboundPort are required for the processes that use GENESIS_CLUSTER as a proxy for the update queue (eg.: DbMon, PurgeTables, etc...).

DbMode: The LEGACY value is no longer supported. The dictionary is always stored in the namespace-aware store, so PostgreSQL works with namespaces/schemas without this setting. If DbMode is set to LEGACY on PostgreSQL, H2 or HSQL, the database fails to start, so remove the setting. In Genesis 8.15 and earlier, DbMode also accepts LEGACY; Genesis 10.0 removed it.

ResourcePollerTimeout: This setting controls how often (in seconds) the genesis daemon process keeps the processes and their metadata up to date.

ReqRepTimeout: This setting contains the default timeout (in seconds) for the request server resources in the system.

DataServerCacheBackend: The cache backend for Data Server queries when neither the query's config nor the Data Server's global config chooses one: LMDB or SQLITE. The value isn't case-sensitive, and an unrecognised value is ignored. Default value is LMDB. For more information, go to the section on choosing the backend.

DataServerNativeColumns: When true, Data Server queries that use SQLite store each field in its own typed column, unless the query's own nativeColumns setting or the global config { sqlite { nativeColumns } } block says otherwise. Default value is false. For the full order in which these apply, go to the section on SQLite settings.

MetadataChronicleMapAverageKeySizeBytes, MetadataChronicleMapAverageValueSizeBytes, MetadataChronicleMapEntriesCount: These are the settings for chronicle map and are related to the way processes store their own metadata resources inside /runtime/proc_metadata.

DaemonServerPort: This defines the port for daemon process, daemon process is the background process, which collects information about micro-services.

JVM_OPTIONS: This defines common JVM options to be applied to all processes defined in the environment.

DbNamespace: This item defines different things, depending on the databases in use:

  • For FoundationDB, this is used when creating internal DirectoryLayers. FoundationDB (the FDB and FDB2 database layers) is deprecated in 10.0 and is planned for removal in 11.0.0. Use the SQL database layer instead.
  • For Postgres, MSSQL and ORACLE, this refers to namespace/schema of database. This enables you to segregate data from multiple apps while using a single database.

ClusterMode: This setting selects how the nodes of your application form a cluster. It can be one of three values:

  • LEGACY, which is the default mode if ClusterMode isn't set; this uses the built-in Akka clustering in GENESIS_CLUSTER, which establishes cluster membership on ClusterPort
  • CONSUL, which uses Consul-based clustering; ClusterPort is not used in this mode
  • DISABLED, which turns clustering off

The value is case-sensitive. If ClusterMode is unset or blank, the mode is LEGACY. Any other value makes startup fail with an error that lists the accepted values. Before 10.0, an unrecognised value was treated as LEGACY.

ClusterPort: This setting specifies the port used by GENESIS_CLUSTER to establish cluster membership between cluster nodes. It is separate from the GENESIS_CLUSTER service port set in the service definitions. ClusterPort is not used when ClusterMode is CONSUL. If it isn't set, GENESIS_CLUSTER uses port 6000. Before 10.0, the port used when it wasn't set was 9900; if your system definition doesn't set ClusterPort and you need to keep that port, set it to 9900 explicitly.

Location: This item contains a 2-character value used to generate the standard ID for a given entity. For example, if a Location item defined as "LO" and entity TRADE has a field called TRADE_ID defined with the sequence "TR", then the generated ID will be 000000000001TRLO1 where "LO" represents Location string. There is more information around compatibility and behaviour of sequences in our page on the Data Model

LogFramework: Kept for compatibility. Genesis no longer uses this item to choose the logging framework; you choose the backend when you build your application. See Choosing a logging backend.

LogFrameworkConfig: Contains the name of the logging configuration file. The default is log4j2-default.xml. If your application uses Logback and this item keeps its default, Genesis loads logback-default.xml instead.

DataDumpJsonFormatEnabled: When true, messages logged because of DATADUMP_ON or DATADUMP_NACK_ON are written as a single JSON string instead of the multi-line format. Default value is false. A process reads this item once, when it starts.

StrictNullChecksEnabled: Controls whether messages that put a null inside a non-null Kotlin collection are rejected. If a class declares a field as a non-null collection, such as List<String>, a message with a null element in that field fails to deserialise. That also covers a null value in a map inside a list, such as List<Map<String, Any?>>, even though the map's values are declared nullable. Default value is true. Set it to false to accept those nulls, as Genesis 8.15 and earlier did. In a GenesisJunit test, use @SysDefOverwrite("StrictNullChecksEnabled", "false").

GlobalClasspathAdditions: A list of delimited (':'), fully-qualified paths to any JVM files to be included on the classpath for all processes.

ProcessDependencyTimeoutSeconds: If you have a dependent process listed in your processes.xml, this config sets a timeout (in seconds) for that process. If the process it depends on is not up, the dependent process will terminate after the timeout period has elapsed.

TransportReadyTimeoutMs: Applies only to processes in the EXTERNAL transport mode. After service registration, the process waits this many milliseconds for its host to signal that it is serving; if the signal doesn't arrive, the process goes to ERROR. Default value is 120000.

StrictHttpStatusCode: When true, the router applies the HTTP status codes found in error responses to the HTTP reply; when false (the default), it returns the error payload in an HTTP 200 response. See Router configuration for details.

RouterOpenApiEnabled: When false, the router switches off its OpenAPI listing. Default value: true.

RouterResourcesRequestEnabled: When false, the router switches off its resources request listing (the reply to RESOURCES_REQUEST). Default value: true.

XssStringSanitizer: When true, string values in the JSON that the router sends to clients over HTTP and WebSocket, and in the JSON replies from HTTP endpoints on a process port, are sanitised against Cross-Site Scripting (XSS). Default value is false. Like StrictHttpStatusCode, it is read by the process that builds the reply. See XSS string sanitisation.

DEPLOYED_PRODUCT: This specifies that the product's generated code is bundled in the product's distribution. This means that remap can skip the code-generation step. This property's value should be the name of the product. To bundle the generated code into the distribution, see here.

BlockGenesisInstall: When true, the genesisInstall command prints a warning and exits without installing anything. Default value: false. Docker images generated by the Genesis Gradle plugin set it to true through the GENESIS_SYSDEF_BlockGenesisInstall environment variable, because configuration changes in a container belong in a new image. See Containers.

For SSL on process communication, see the service definition page.

Expression limits​

From version 10.0.1, expressions sent by a client or a user are checked against three limits before they are parsed or compiled:

  • a client's CRITERIA_MATCH on a Data Server or Request Server
  • RULE_EXPRESSION and RESULT_EXPRESSION when a dynamic rule is inserted or amended, and RESULT_EXPRESSION when a cron rule is inserted or amended
  • RULE_EXPRESSION and RESULT_EXPRESSION of the dynamic rule created when a user subscribes to a rule template

Only the text the client sends is checked. Criteria that your application defines, such as a query's criteria template, aren't counted.

ItemDefaultWhat it counts
ExpressionMaxLength65536Characters in the expression
ExpressionMaxNestingDepth100The deepest nesting of (, [ and { brackets
ExpressionMaxLogicalOperators1000Logical operators: &&, ||, !, ?: and the ternary ?, plus &, | and ^

!= and the safe-navigation operator ?. aren't counted as logical operators.

Set an item to 0 or below to disable that limit.

Brackets and operators inside a single-quoted string, or inside a double-quoted string without $, aren't counted, and neither are comments. After a $, a # or a slashy string (/…/), the check can no longer tell code from text. From that point on, it counts brackets and operators inside strings and comments too, and every opening bracket counts as one more level of nesting, even after it closes. An expression with many separate bracket groups can then be refused even though it isn't deeply nested; the error message says so. An expression that contains a \u escape is refused.

An expression over a limit is refused with a message that names the item, for example Expression exceeds ExpressionMaxNestingDepth: 101 > 100:

  • Criteria are refused with the error code INVALID_CRITERIA.
  • A rule insert or amend event is rejected with the same message.
warning

This is a breaking change in 10.0.1: an expression over the defaults is now refused where it was accepted before. If your application needs larger expressions, raise the limits, but read Raising the limits first.

Raising the limits​

Groovy's parser, which reads these expressions, uses more thread stack the more deeply an expression is nested. Raising a limit doesn't let the parser handle more than the stack allows. Past that point, the expression is still refused, with the message Expression is nested too deeply to parse instead of one that names a limit, and not always with INVALID_CRITERIA:

  • A Data Server returns INVALID_CRITERIA.
  • A Request Server returns REQUEST_FAILED, and a custom Request Server returns GENERIC_ERROR.
  • A rule insert or amend event is rejected with that message.

These figures are for a 1 MB thread stack, the JVM default on Linux x64, measured with Groovy 3.0.25 on a JVM that had just started (the worst case):

Expression shapeParsesFails
A || B || … chain1,000 clausesby 2,000 clauses (about 20,000–40,000 characters)
Nested brackets, ((…))300 levels342 levels
Repeated !1,000about 1,560
FIELD in [...] listNo failure up to 1.5 MB of text—

On a 1 MB stack, keep ExpressionMaxNestingDepth at or below 300 and ExpressionMaxLogicalOperators at or below 1000. Length on its own doesn't strain the parser: a long flat list parses, so you can raise ExpressionMaxLength further if your expressions are flat. To go beyond these figures, increase the thread stack size of the process (for example, -Xss2m in its <options> in processes.xml). On a 2 MB stack, an || chain fails at about 4,100 clauses, and nested brackets fail at 782 levels.

For dynamic and cron rules, a second nesting check runs on the parsed expression, and it is capped at 100 levels. ExpressionMaxNestingDepth can lower that cap but can't raise or disable it. This check counts nested operators and method calls, not brackets: each && or || in a chain adds a level, and so does each call in a chain such as NAME.trim().trim(). So a rule expression with a flat chain of more than about 100 conditions is refused with Nesting deeper than 100 levels is not allowed in a dynamic rule, even though it is within ExpressionMaxLogicalOperators.

GPal script caching settings​

These settings control compilation and caching of GPal scripts and system-definition files. Because these files rarely change between restarts, using cached versions speeds up process start-up and reduces memory use.

ScriptCacheDir: The directory used for script caching. Defaults to $GENESIS_HOME/runtime/scriptcache if not set.

ScriptCachePerService: When true, the script cache is process-specific rather than shared. Defaults to false if not provided. Process-specific caching avoids cross-process cache conflicts and can make startup more reliable.

These settings apply only to scripts that a process compiles at start-up. If your build compiles scripts at build time, the process loads those scripts from their compiled classes and doesn't use the script cache for them.

Setting system-definition values from environment variables​

You can override system-definition values in any environment by using environment variables. To do this, you can set an environment variable that has the same name as the system-definition item name prefixed with GENESIS_SYSDEF_ or GENESIS_ENCRYPTED_SYSDEF_.

GENESIS_ENCRYPTED_SYSDEF_ needs to be used where the value of the system definition is sensitive and is encrypted (e.g. for sensitive content you do not wish to go into any code repository in plain text) as explained under the Items defined / Database username and password encryption section above.

Here is an example where system definition items DbHost, DbUser, DbPassword and GenesisKey are all being set via environment variables. These values will override the configuration found in the system definition file:

GENESIS_SYSDEF_DbHost=jdbc:postgresql://localhost/genesis
GENESIS_ENCRYPTED_SYSDEF_DbUsername=ab8b6921e904a1dbf058041ae176f27323ed2f835c0a5276b307ef539f6ef6d9
GENESIS_ENCRYPTED_SYSDEF_DbPassword=a8a4d770afe25446434c2a13fa614be74274220c10a5b8346cf5629807374d2a
GENESIS_SYSDEF_GenesisKey=ABCDEFGHIJKLMNOPQRSTUVWXYZ123456

Process-scoped system-definition overrides​

System-definition items can be set at process scope (for example inside a *-process-config.kts file using process { systemDefinition { ... } }).

process {
systemDefinition {
item("HttpAuthDisabled", "true")
}
}

The *-process-config.kts file only applies to a process if that process names it in a <config> element in processes.xml. See the config tag on the processes page.

You can also set them as environment variables. To do this, prefix the variable name with the process name:

  • GENESIS_SYSDEF_<PROCESS_NAME>_<ItemName>=...

If both a global override (GENESIS_SYSDEF_<ItemName>) and a process-scoped override are set, the process-scoped override takes precedence for that process only.

You can't set a per-process value in genesis-system-definition.kts by prefixing the item name with the process name; a prefixed item there is never read, and the unprefixed item applies. To set a value for one process in a file, use the process { systemDefinition { ... } } form in that process's *-process-config.kts, as above.

For example:

GENESIS_SYSDEF_DbSqlMaxPoolSize=10
GENESIS_SYSDEF_GENESIS_AUTH_MANAGER_DbSqlMaxPoolSize=50

In this example, all processes will use DbSqlMaxPoolSize=10 by default, but the GENESIS_AUTH_MANAGER process will use DbSqlMaxPoolSize=50.

For local development under Genesis Start only, you can also use per-process system-definition properties files; see System definition property overrides. These files do not apply in a deployed environment, where processes use the environment-variable forms described above.

Overriding processes.xml settings​

You can override the values defined for a process definition inside the processes.xml file by using the following naming convention: <PROCESS_NAME>_PROCESS_<property>

This approach makes it really easy to set the properties for a process definition without having to override/modify the corresponding processes.xml file directly, which simplifies the deployment process and long term maintenance. Additionally, this mechanism works both for a local development environment (using Genesis Start or the IntelliJ plugin) and for a deployed environment.

For example, to set the start property to false for a process named GENESIS_AUTH_PERMS with the following configuration:

    <process name="GENESIS_AUTH_PERMS">
<groupId>AUTH</groupId>
<start>true</start>
<scheduleRestart>true</scheduleRestart>
<options>-Xmx256m -DXSD_VALIDATE=false</options>
<module>auth-perms</module>
<package>global.genesis.auth.perms</package>
<description>Manages entity level user authorisation</description>
</process>

You can set the following system definition property in your genesis-system-definition.kts file:

item(name = "GENESIS_AUTH_PERMS_PROCESS_START", value = "false")

The process property names follow the uppercase underscore naming convention for consistency with the process name. See table below with all the available properties and the mapping to the corresponding xml tags in processes.xml :

Sysdef NameXML tag Name
GROUP_ID<groupId>
DESCRIPTION<description>
START<start>
OPTIONS<options>
CONFIG_OVERRIDES_FILE<configOverridesFile>
MODULE<module>
PACKAGE<package>
PRIMARY_ONLY<primaryOnly>
CLASSPATH<classpath>
SCHEDULE_RESTART<scheduleRestart>
ARGUMENTS<arguments>
COMPACT_PROCESS<compactProcess>
CONFIG<config>
SCRIPT<script>
LOGGING_LEVEL<loggingLevel>
DEPENDENCY<dependency>
LANGUAGE<language>
info

<PROCESS_NAME>_PROCESS_OPTIONS replaces the process's <options> tag entirely, whether you set it with a system definition item or an environment variable. Nothing from the tag is kept, so repeat any flags you still need, such as -DRedirectStreamsToLog=true.

The global JVM_OPTIONS item is still merged in. If both set -Xmx or -Xms, the value from <PROCESS_NAME>_PROCESS_OPTIONS wins. Without an override, the value from JVM_OPTIONS wins over the process's own <options> tag.

Genesis starts every process with -XX:+IgnoreUnrecognizedVMOptions, so the JVM silently ignores any -XX: flag it doesn't recognise, including a misspelt one. Check the spelling of any -XX: flags you add.

Overriding at start time​

startProcess also reads these overrides each time it starts a process. preCompileScripts reads them the same way, so pre-compiled scripts match what startProcess runs. For a process <PROCESS_NAME> and a property <property>, the value comes from the first of these that is set:

  1. the environment variable GENESIS_SYSDEF_<PROCESS_NAME>_PROCESS_<property>
  2. the system definition item <PROCESS_NAME>_PROCESS_<property>
  3. the tag in processes.xml
  4. the tag's default

<PROCESS_NAME> must match the process name in processes.xml exactly. The lookup is case-sensitive, so GENESIS_SYSDEF_genesis_auth_perms_PROCESS_OPTIONS is ignored for a process named GENESIS_AUTH_PERMS.

An environment variable takes effect the next time you run startProcess; you don't need to run genesisInstall. A system definition item is read from the installed system definition, so it still needs genesisInstall.

At start time, this covers PACKAGE, OPTIONS, CONFIG, LOGGING_LEVEL, CONFIG_OVERRIDES_FILE, SCRIPT, LANGUAGE, MODULE, ARGUMENTS and CLASSPATH. The other properties in the table are applied when genesisInstall generates processes.xml.

For example, this changes the JVM options of GENESIS_AUTH_PERMS the next time it starts:

export GENESIS_SYSDEF_GENESIS_AUTH_PERMS_PROCESS_OPTIONS="-Xmx1g -DXSD_VALIDATE=false"
startProcess GENESIS_AUTH_PERMS

Don't confuse these names with process-scoped system-definition overrides. GENESIS_SYSDEF_<PROCESS_NAME>_<ItemName> sets a system definition item for one process; GENESIS_SYSDEF_<PROCESS_NAME>_PROCESS_<property> sets one of its processes.xml properties.

Retrieving system-definition properties​

There are examples of how to retrieve properties from an application's system definition in our page on dependency injection in the API section.

Genesis enables you to store encrypted values in the configuration. You can access the encrypted values from custom components using:

By default, you can inject those values into your classes using a syntax such as:

@Named("DBUSERNAME") val passwordString: String

This is then decrypted by the platform into memory.

Protecting against memory scanning​

To reduce the risk of a malicious attacker being able to run a memory scan on a running instance and acquire the decrypted value, the platform enables you to:

  • delay decrypting of the value by using a Provider wrapper, and
  • obfuscate the scanning of the value by using a ByteArray instead of a String; this approach requires you to deserialize back to a String at the point of use.

The Provider ByteArray provides the best protection against memory scanning for passwords from a malicious agent, because the password is not decrypted until the point of use and doesn’t present itself as an ordinary string.

There are various ways you can pull an encrypted value into a Kotlin class.

  • String - means that the encrypted value will be decrypted in memory immediately.
  • ByteArray - loaded as a decrypted ByteArray, adds some obfuscation by not using a String directly.
  • Provider<String> - will not be decrypted until the moment that the value is required via the get.
  • Provider<ByteArray> - will not be decrypted until the moment that the value is required via the get.
@Module
class TestModule
@Inject
constructor(
@Named("DBUSERNAME") val passwordString: String,
@Named("DBUSERNAME") val passwordByteArray: ByteArray,
@Named("DBUSERNAME") val passwordByteArrayProvider: Provider<ByteArray>,
@Named("DBUSERNAME") val passwordStringProvider: Provider<String>
) {
init {
assertThat(passwordStringProvider.get()).isEqualTo("johndoe")
assertThat(passwordString).isEqualTo("johndoe")

assertThat(passwordByteArrayProvider.get().toString(Charsets.UTF_8)).isEqualTo("johndoe")
assertThat(passwordByteArray.toString(Charsets.UTF_8)).isEqualTo("johndoe")
}
}

Specifying multiple environments​

When you need to override any of the config settings for a deployment (for example, if you want to use a different database in a specific environment), create a new system block in your application's *-system-definition.xls with the required settings for the environment. For example, if you want to use different databases in UAT and DEV environments, specify the settings for each in a separate system block:

systems {
...
system(name = "DEV") {
hosts {
host(LOCAL_HOST)
}
item(name = "DbHost", value = "dbc:postgresql://devdb:5432/postgres?user=dev&password=dev")
}
system(name = "UAT") {
hosts {
host("uat1.myorg.global")
}
item(name = "DbHost", value = "dbc:postgresql://uatdb:5432/postgres?user=uat&password=uat")
}
}

During runtime the hosts block will be read to find configurations applicable to this host.

In a systems { } block, genesisHosts(environment) returns the hosts declared for the system whose name is environment, as a list of GenesisHost objects. It returns an empty list if no system has that name. It replaces dtaHosts(environment), which was removed in 10.0.

important

LOCAL_HOST special behavior: Any system using the LOCAL_HOST special value will always match in any environment, and therefore must be defined at the bottom of the system definition file.

By defining LOCAL_HOST at the bottom of the system definition file, the application will try to match other system blocks in sequence first, avoiding the scenario where a "DEV" system with LOCAL_HOST would match when a more specific "UAT" or "PROD" system block should be used instead.

LOCAL_HOST is most useful for local development (like running a Genesis application using Genesis Start or the IntelliJ plugin).

HashiCorp Vault support​

important

This feature is supported from version 6.0

Services can also load their configuration from HashiCorp vault. This can be done by adding a vault tag in the global, system or host tags.

The vault tag has three sub tags, config, sslConfig and readSecrets. Of these three, config and readSecrets are required:

vault {
config {
...
}

sslConfig {
...
}

readSecrets {
...
}
}

Config​

This part of the configuration tells the service where to read secrets from:

config {
address("http://localhost:8200") // Defaults to "VAULT_ADDR" environment variable
token("s.NSxyuF4ClXxd4YoSFvKwil0i") // Defaults to "VAULT_TOKEN" environment variable
openTimeout(5) // Defaults to "VAULT_OPEN_TIMEOUT" environment variable
readTimeout(30) // Defaults to "VAULT_READ_TIMEOUT" environment variable
}

sslConfig​

This part of the configuration tells the service how to handle the ssl hand shake with the vault server. For details regarding the ssl config, please see here. Note that the SslConfig object will be passed as the receiver within the sslConfig tag.

readSecrets​

This part of the configuration tells the service which secrets to load:

readSecrets {
read("secret/path_to_secret")
}

Currently, a single call to read is supported. This takes a single parameter, which is the path to the secrets.

Secrets are always provided as String

Linked properties support​

important

This feature is supported from version 6.0

When reading secrets from external systems, the keys to these secrets might not map directly to the required properties in Genesis. To help with this, the platform supports the linking of properties.

The links can be applied as tags at global, system or host level.

To create a link, use link, as per below, where we link DbHost to secret.db.host:

systemDefinition {
global {
link(name = "DbHost", source = "secret.db.host")
}
...
}

Multiple levels of linking are supported. However, genesisInstall will fail if a circular link is detected, or if the source of a link is not found.

API​

The system-definition file is the basis of all configurations. In this page, we describe the different functions available to get properties specified in the *-system-definition.kts files. Default methods have implementations to provide default values for each property.

Most of the functions are to get or set a particular property.

If you add any other property whose getter or setter function is not available, use the functions get or getItem.

You can access system definition properties in two ways:

  • using existing APIs
  • using @Named Genesis annotation

Using existing APIs​

namesignature
availableProperties@NotNull default Set<String> availableProperties()
determineEnvironment@NotNull default String determineEnvironment()
get@NotNull default Optional<String> get(String key)
getAeronArchiveEnabledFlagdefault Optional<Boolean> getAeronArchiveEnabledFlag()
getAeronIpRangedefault Optional<String> getAeronIpRange()
getAeronServicePortdefault Optional<Integer> getAeronServicePort()
getChronicleMapAverageKeySizeBytesdefault Optional<String> getChronicleMapAverageKeySizeBytes()
getChronicleMapAverageValueSizeBytesdefault Optional<String> getChronicleMapAverageValueSizeBytes()
getChronicleMapEntriesCountdefault Optional<String> getChronicleMapEntriesCount()
getDaemonServerPortdefault Optional<String> getDaemonServerPort()
getDatabaseHostnamedefault Optional<String> getDatabaseHostname()
getDatabasePortdefault Optional<String> getDatabasePort()
getDbNamespacedefault Optional<String> getDbNamespace()
getDefaultCertificateLocationdefault Optional<String> getDefaultCertificateLocation()
getDefaultKeystoreLocationdefault Optional<String> getDefaultKeystoreLocation()
getDefaultKeystorePassworddefault Optional<String> getDefaultKeystorePassword()
getHostdefault GenesisHost getHost(String hostName)
getHostsList<GenesisHost> getHosts()
getItem@Nullable Object getItem(String key)
getLogFrameworkdefault Optional<String> getLogFramework()
getLogFrameworkConfigdefault Optional<String> getLogFrameworkConfig()
getReqRepTimeoutdefault Optional<String> getReqRepTimeout()
getValueOrDefault@NotNull default String getValueOrDefault(String key, @NotNull String defaultValue)
getZeroMQInboundPortdefault Integer getZeroMQInboundPort()
getZeroMQOutboundPortdefault Integer getZeroMQOutboundPort()
getZeroMQProxyModeEnableddefault Boolean getZeroMQProxyModeEnabled()
getZeroMQUnicastRelayEnableddefault Boolean getZeroMQUnicastRelayEnabled()
isAuthDisableddefault boolean isAuthDisabled()
isClusteringEnableddefault boolean isClusteringEnabled()
isEncrypteddefault boolean isEncrypted(String key)
isMetricsEnabledboolean isMetricsEnabled()
parsePropertystatic <T, R> Optional<R> parseProperty(Supplier<Optional<T>> property, Predicate<? super T> canBeTransformed, Function<? super T, ? extends R> transformer)
parseStringPropertystatic <R> Optional<R> parseStringProperty(Supplier<Optional<String>> property, Function<? super String, ? extends R> transformer)

Using @Named genesis annotation​

Injectable properties from system definition​

Here is an example of a genesis-system-definition.kts file:

systemDefinition {
global {
item(name = "CONFIG_FILE_NAME", value = "/data/")
// other params omitted for simplicity
}
}

Here is an example of a system definition property being referenced in a Java file:

@Inject
public RequestReplyDefinitionReader(RxDb db,
@Named("CONFIG_FILE_NAME") String configFileName) throws GenesisConfigurationException {
this(db.getDictionary(), configFileName);
}