Configuration File

Sample configuration file

An example of a complete configuration file is available here.

Configuration options

Note: The following options are fully available from RESTHeart version 3.7.0.

Properties files

Starting from RESTHeart 3.7.0 it is possibile to pass an optional properties file as a startup parameter or via a environment variable:

For example, the file in etc/ folder contains the following properties:

instance-name = development
default-representation-format = PLAIN_JSON
mongo-uri = mongodb://

idm.conf-file = ../etc/security.yml
access-manager.conf-file = ../etc/security.yml

log-level = DEBUG

query-time-limit = 0
aggregation-time-limit = 0

The restheart.yml file contains the above parameters, expressed with the “Mustache syntax” (triple curly braces to indicate parametric values). Have a look at the below fragment for an example:

instance-name: {{{instance-name}}}

default-representation-format: {{{default-representation-format}}}

mongo-uri: {{{mongo-uri}}}

  conf-file: {{{idm.conf-file}}}
  conf-file: {{{access-manager.conf-file}}}

log-level: {{{log-level}}}

query-time-limit: {{{query-time-limit}}}

aggregation-time-limit: {{{aggregation-time-limit}}}

The implementation uses the library, which is a derivative of mustache.js, to create parametric configurations for RESTHeart.

Of course, you can decide which values in restheart.yml you want to become parametric or you can just use a static file as before version 3.7, this new configuration with properties is fully optional.

To start RESTHeart and provide it with a properties file pass the --envfile command line parameter:

java -Dfile.encoding=UTF-8 -server -jar target/restheart.jar etc/restheart.yml --envfile etc/

Alternatively, pass the envfile path via RESTHEART_ENVFILE environment variable:

$ java -Dfile.encoding=UTF-8 -server -jar target/restheart.jar etc/restheart.yml

This approach allows to share one single configuration file among several environments. For example, one could create, and, one for each environment, with one single common restheart.yml configuration file.

Environment variables

RESTHeart 3.7.0 introduces also the possibility to override any primitive type parameter in restheart.yml with an environment variable. Primitive types are:

  • String
  • Integer
  • Long
  • Boolean

For example, the parameter mongo-uri in the yaml file can be overridden by exporting a MONGO_URI environment variable:

$ export MONGO_URI="mongodb://"

The following log entry appears at the very beginning of logs during the startup process:

[main] WARN  org.restheart.Configuration - >>> Overriding parameter 'mongo-uri' with environment value 'MONGO_URI=mongodb://'

A shell environment variable is equivalent to a yaml parameter in restheart.yml, but it’s all uppercase and '-' (dash) are replaced with '_' (underscore).

Remember: environment variables replacement doesn’t work with YAML structured data in configuration files, like arrays or maps. You must use properties files and mustache syntax for that.

Command line parameters

To know the available CLI parameters, run RESTHeart with --help:

$ java -jar target/restheart.jar --help
Usage: java -Dfile.encoding=UTF-8 -jar -server restheart.jar [options] 
      <Configuration file>
    --envFile, --envfile, -e
      Environment file name
      Fork the process
      Default: false
    --help, -?
      This help message