Site configuration options

Database

We currently support sqlite3, postgres and cockroach databases.

Name Type Env Values Default Description
Type string DB_TYPE postgres,sqlite3 Database type
Dsn string DB_CONNECTION Database url
Host string DB_HOST Database host
Port uint DB_PORT 1-65535 Database port
Name string DB_NAME Database name
User string DB_USER Database user
Pass string DB_PASS database password
ConnMaxLifetime time duration DB_CONN_MAX_LIFETIME “100s”,“10m” Connection life time
MaxIdleConns int DB_MAX_IDLE_CONNS Max idle connections
MaxOpenConns int DB_MAX_OPEN_CONNS Max open connections
ReadOnly bool DB_READ_ONLY false Read only mode
Migrate bool DB_MIGRATE false Enable migrations

If you use dsn you don’t need to specify database type, host, port, name, user or pass.

Migrations

Upon startup the system checks if there are any pending database schema migrations and applies them in sequence. If one of the migrations fail everything gets rolled back and the startup fails with details in its log output.

The migrate setting allows you to control automatic schema migrations. If you want to update or upgrade the system you must set this to true.

Database opts

The opts setting allows you to set additional configuration parameters for the database.

Name Type Env Values Default Description
Set string Option setting
Val string Option value

The options you can set depends on the database type and version you are using.

Example sqlite3 database configuration.

[database]
type = "sqlite3"
name = "/storage/site.db"
migrate = true
[[database.opts]]
set = "foreign_keys"
val = "ON"
[[database.opts]]
set = "journal_mode"
val = "WAL"

The database file gets created if it doesn’t exist.

Example Postgres database configuration.

[database]
type = "postgres"
name = "site"
user = "postgres"
pass = "postgres"
host = "127.0.0.1"
port = 5432
migrate = true

If you have granted create database permission to the db user the database is created.

Example Cockroach database configuration using dsn.

[database]
dsn = "cockroach://root@localhost:26257/site?sslmode=disable"
migrate = true

You must first create the site database in cockroach or it will use defaultdb instead.

Server

Server configuration options.

Name Type Env Values Default Description
Host string SITE_SERVER_HOST hostname or IP Server host (NATS)
Port uint SITE_SERVER_PORT 1-65535 4222 Server port (NATS)
Dir string SITE_SERVER_DIR Server dir (NATS/Jetstream)

When server HOST is unset or if set to localhost or 127.0.0.1 it embeds a NATS messaging backend service. Otherwise it attaches itself to the nats://HOST:PORT service.

Example

[server]
Host: "message.server.int"
Port: 4222
Dir: "/tmp"

Cluster

Site cluster configuration.

Name Type Env Values Default Description
Name string SITE_CLUSTER_NAME Cluster name
Host string SITE_CLUSTER_HOST Cluster host
Port uint SITE_CLUSTER_PORT Cluster port
Routes []string SITE_CLUSTER_ROUTES Cluster routes / peers