Configuration Guide

Beiran configuration is managed by module config.py. This module provides a global config object holding all configuration parameters.

Config object loads all values from a toml file and / or environment variables. Environment variables override all others, if a corresponding value provided.

All environment variables starts with BEIRAN_ and you can find a a list of them in module’s documentation section below.

A sample config.toml file is below. Copy, edit and use it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# beiran configuration file

# general settings which is valid all parts, lib, daemon and all plugins
[beiran]
log_level = 'DEBUG'
log_file = '/var/log/beirand.log'
config_dir = '/etc/beiran'
data_dir = '/var/lib/beiran'
run_dir = '/var/run'
listen_port = 8888
listen_address = '0.0.0.0'
socket_file = '/var/run/beirand.sock'
discovery_method = 'zeroconf'

# docker plugin settings
[package.docker]
enabled = true
cache_dir = '/var/cache/beiran/docker'

# dns discovery settings
[discovery.dns]
enabled = true

# zeroconf discovery settings
[discovery.zeroconf]
enabled = true

Also, a copy of config.toml can be found in installation directory. Installation directory’s location depends on your platform and installation way.

Warning

Do not forget setting BEIRAN_CONF_FILE env variable pointing your tuned file or using parameter –config if you prefer beiran cli binary.

class beiran.config.Config(config_file=None)[source]

Bases: object

Configuration object holds configuration parameters as class properties. It overrides default values by values from config toml file or environment.

cache_dir

A directory used to store cached files. The default value is /var/cache/beiran.

config.toml: section beiran, key cache_dir

Environment variable: BEIRAN_CACHE_DIR

config_dir

A directory is used to store configuration files. The default value is /etc/beiran.

config.toml: section beiran, key config_dir

Environment variable: BEIRAN_CONFIG_DIR

data_dir

A directory is used to store miscellaneous beiran data. The default value is /var/lib/beiran.

config.toml: section beiran, key data_dir

Environment variable: BEIRAN_DATA_DIR

db_file

A file path for database. The default value is /var/lib/beiran/beiran.db.

config.toml: section beiran, key db_file

Environment variable: BEIRAN_DB_FILE

discovery_method

Service discovery method for beiran daemons to find each others. The default value is None. It can be eighter zeroconf, dns or any other discovery plugins name.

config.toml: section beiran, key discovery_method

Environment variable: BEIRAN_DISCOVERY_METHOD

enabled_plugins

Returns enabled plugin list.

Returns:enabled plugins specified in config file or env
Return type:(list)

Iterates installed packages and modules to match beiran modules.

returns:list of package name of installed beiran plugins.
rtype:list
hostname

Beiran daemon’s hostname. The default value is None

config.toml: section beiran, key hostname

Environment variable: BEIRAN_HOSTNAME

known_nodes

List of URLs of known nodes. Beiran daemon tries to communicate with them. The default value is []

config.toml: section beiran, key known_nodes

Environment variable: BEIRAN_KNOWN_NODES

listen_address

Beiran daemon’s listen address. It can be any valid IP address. The default value is 0.0.0.0

config.toml: section beiran, key listen_address

Environment variable: BEIRAN_LISTEN_ADDRESS

listen_interface

Beiran daemon’s interface. The default value is None

config.toml: section beiran, key listen_interface

Environment variable: BEIRAN_LISTEN_INTERFACE

listen_port

Beiran daemon’s running port. It can be any available tcp port on host. The default value is 8888

config.toml: section beiran, key listen_port

Environment variable: BEIRAN_LISTEN_PORT

Load config values from given file :param config_file: file path :type config_file: str

Returns:

log_file

A file path for storing logs. The default value is /var/log/beirand.log.

config.toml: section beiran, key log_file

Environment variable: BEIRAN_LOG_FILE

log_level

Logging level. The default value is DEBUG. Beiran use Python Standard Lib’s logging module. Standard logging level strings are valid. Please see logging module in standard library further details.

config.toml: section beiran, key log_level

Environment variable: BEIRAN_LOG_LEVEL

run_dir

A directory used to store beirand.sock. The default value is /var/run.

config.toml: section beiran, key run_dir

Environment variable: BEIRAN_RUN_DIR

socket_file

A file path for socket. The default value is /var/run/beirand.sock.

config.toml: section beiran, key socket_file

Environment variable: BEIRAN_SOCKET_FILE

url

Beiran daemon’s URL. The default value is None

config.toml: section beiran, key url

Environment variable: BEIRAN_URL