Skip to content

Server Configuration

There are two methods for configuring the sever. Either by using a configuration file, or environment variables. Select between the two tabs to show examples of which source you require.

Configuration Sources

TOML

There are a few default locations that the server will look for configuration files

  • /etc/warecache/config.toml
  • ~/.local/config/warecache/config.toml
  • ./wcd_config.toml

The more local the file is, the higher the precedence in settings. An example configuration file is shown below.

[general]
debug = true

[log]
output="std"
level="debug"
file="test.log"

[api]
port = 8118
address = '0.0.0.0'
externurl= 'localhost'

[db]
address = 'localhost'
port = 0

[userdb]
address = 'localhost'
port = 5432
user = "warecached"
pass = "CHANGE_ME_PASSWORD"
db = "wc_test"

[mqtt]
address = 'warecache.example.com'
port = 8883
clientid = "example-server"
keepalive = 30
certpath = "./certs/client.crt"
keypath = "./certs/client.key"
rootcapath = "./certs/ca.crt"

Environment

Environment variables will overwrite configuration settings. The format for environment variables is the prefix WCD, with each configuration group and then individual setting. The delimiter is _.

An example variable for the api listen address is WCD_API_ADDRESS

Settings

General

Generic settings

Debug

Enables or disables debug mode.

Setting
[general]
debug = BOOL
WCD_GENERAL_DEBUG=BOOL
Acceptable values
Value Description
True Enable Debug mode
False Disable Debug mode

log

Settings for output logs. The output can be to a file, to stdout, or syslog. If if the output is set to file, then the file setting must also be configured.

Output

Setting
[log]
output="string"
WCD_LOG_OUTPUT="string"
Acceptable values
Value Description
std Log to STDIO
file Log to file
syslog Log to syslog

Level

Settings for log levels. Each level incoroprates the prior levels. Use this setting to filter out unwanted messages in the logs, or to debug issues.

Setting
[log]
level="string"
WCD_LOG_LEVEL="string"
Acceptable values
Value Description
error Enable Error messages
warn Enable Warning messages and above
info Enable Info messages and above
debug Enable Debug messages and above

File

Optional setting. It is only required when using the output log of file. It should be a path to the file; relative or absolute.

Setting
[log]
file="string"
WCD_LOG_FILE="/path/to/file"
Acceptable values
Value Description
File Path Path to file

API

API specific settings

Address

The address that the API should listen to. This can be an IP address or FQDN.

Setting
[api]
address="string"
WCD_API_ADDRESS="string"
Acceptable values
Value Description
String IP Address or FQDN

Port

The port the API service should listen to.

Setting
[api]
port = 30
WCD_API_PORT="/path/to/file"
Acceptable values
Value Description
Integer Port number

External URL

The external URL that the API service should expect. This is required for CORS. The URL used here should be identical to the one that is used for creating the certificates.

Setting
[api]
externurl="string"
WCD_API_EXTERNURL="string"
Acceptable values
Value Description
String IP Address or FQDN

DB

Item Database settings

Address

The item database address. Can be a FQDN, or ip address.

Setting
[db]
address="string"
WCD_DB_ADDRESS="string"
Acceptable values
Value Description
String IP Address or FQDN

Port

The item database port.

Setting
[db]
port = 30
WCD_DB_PORT="/path/to/file"
Acceptable values
Value Description
Integer Port number

UserDB

User Account Database settings

Address

The user database address. Can be a FQDN, or ip address.

Setting
[userdb]
address="string"
WCD_USERDB_ADDRESS="string"
Acceptable values
Value Description
String IP Address or FQDN

Port

The user database port.

Setting
[userdb]
port = 30
WCD_USERDB_PORT="/path/to/file"
Acceptable values
Value Description
Integer Port number

Username

The username to authenticate with the user database.

Setting
[userdb]
user="string"
WCD_USERDB_USER="string"
Acceptable values
Value Description
String Username

Password

The password to authenticate with the user database.

Setting
[userdb]
pass="string"
WCD_USERDB_PASS="string"
Acceptable values
Value Description
String Password

Database Name

The database name for the user database.

Setting
[userdb]
db="string"
WCD_USERDB_DB="string"
Acceptable values
Value Description
String Database Name

MQTT

MQTT Connection Settings

Address

The MQTT server address. Can be a FQDN or an ip address.

Setting
[mqtt]
address="string"
WCD_MQTT_ADDRESS="string"
Acceptable values
Value Description
String IP Address or FQDN

Port

The MQTT server port. Should be 8883 for secured connections. All branded warecache devices support encrypted MQTT connections. Be weary of security risks without secured connections.

Setting
[mqtt]
port = 30
WCD_MQTT_PORT="/path/to/file"
Acceptable values
Value Description
Integer Port number

Client ID

The client name for the server to use when connecting to the MQTT server. It will appear in the MQTT server logs for reference.

Setting
[mqtt]
clientid="string"
WCD_MQTT_CLIENTID="string"
Acceptable values
Value Description
String Client ID

Keepalive

The required keepalive ping to the MQTT server from the client. Some MQTT servers will disconnect if the proper keepalive is not set.

Setting
[mqtt]
keepalive = 30
WCD_MQTT_KEEPALIVE="/path/to/file"
Acceptable values
Value Description
Integer Keepalive in seconds

Client Certificate

The x509 certificate that the server uses to authenticate with the MQTT server.

Setting
[mqtt]
certpath="string"
WCD_MQTT_CERTPATH="/path/to/file"
Acceptable values
Value Description
File Path Path to file

Client Key

The x509 key that the server uses to authenticate with the MQTT server.

Setting
[mqtt]
keypath="string"
WCD_MQTT_KEYPATH="/path/to/file"
Acceptable values
Value Description
File Path Path to file

Root Certificate Authority

The root certificate authority that signed the client certificate.

Setting
[mqtt]
rootcapath="string"
WCD_MQTT_ROOTCAPATH="/path/to/file"
Acceptable values
Value Description
File Path Path to file