.env file

View as Markdown

This documentation is specific to the configuration when building Krenalis from source. If you started Krenalis using Docker Compose, see the related documentation.

In addition to setting environment variables before starting Krenalis, you can place them in a .env file located in the same directory where you run the executable. Krenalis will read variables from this file, but it will never override values already defined in the environment. Environment variables always take precedence over those in the .env file.

A ready-to-use .env file is provided in the repository: .env.example. You can rename this file to .env and customize it as needed. It includes all environment variables supported by Krenalis.

Example

This is an example of .env file:

# Server settings
KRENALIS_HTTP_HOST=127.0.0.1
KRENALIS_HTTP_PORT=2022

# TLS settings
KRENALIS_HTTP_TLS_ENABLED=true
KRENALIS_HTTP_TLS_CERT_FILE="/etc/ssl/certs/my krenalis cert.crt"
KRENALIS_HTTP_TLS_KEY_FILE='/etc/ssl/private/krenalis.key' # key file

# Commented out value
#KRENALIS_HTTP_PORT=8080

# With export
export KRENALIS_HTTP_READ_TIMEOUT=10s

Syntax

The .env file is a simple list of key-value pairs used to configure environment variables. Here's how it works:

  • One variable per line: KEY=VALUE.
  • Lines starting with # or empty lines are ignored.
  • Lines can start with export .
  • Keys and values cannot contain NUL characters.
  • Values can be:
    • Unquoted — spaces at the end are kept; inline comments start with #.
    • Double-quoted — supports \n, \r, \t, \\, \".
    • Single-quoted — supports only \'.
  • Values after a closing quote must have only spaces or a comment.
  • Variables in the file override existing environment values.
  • Use true or false for booleans. Don't use 1 or 0.
  • File paths can be absolute or relative; relative paths are based on the working directory of the Krenalis process.