Add configurable LOG_LEVEL env vars.
Some checks failed
Build Golang packages / release (push) Waiting to run
Build Docker image / build (push) Has been cancelled

This commit is contained in:
Pieter Hollander 2024-07-27 00:42:51 +02:00
parent b63c1e85d3
commit 3556e401bc
Signed by: pieter
SSH key fingerprint: SHA256:HbX+9cBXsop9SuvL+mELd29sK+7DehFfdVweFVDtMSg
7 changed files with 21 additions and 0 deletions

View file

@ -32,6 +32,7 @@ services:
OPENDTU_PASSWORD: ${OPENDTU_PASSWORD} OPENDTU_PASSWORD: ${OPENDTU_PASSWORD}
TIMESCALEDB_ENABLED: ${TIMESCALEDB_ENABLED} TIMESCALEDB_ENABLED: ${TIMESCALEDB_ENABLED}
TZ: ${TZ} TZ: ${TZ}
LOG_LEVEL: ${LOG_LEVEL}
depends_on: depends_on:
timescaledb: timescaledb:
condition: service_healthy condition: service_healthy

View file

@ -32,6 +32,8 @@ services:
OPENDTU_PASSWORD: ${OPENDTU_PASSWORD} OPENDTU_PASSWORD: ${OPENDTU_PASSWORD}
TIMESCALEDB_ENABLED: ${TIMESCALEDB_ENABLED} TIMESCALEDB_ENABLED: ${TIMESCALEDB_ENABLED}
TZ: ${TZ} TZ: ${TZ}
LOG_LEVEL: ${LOG_LEVEL}
depends_on: depends_on:
timescaledb: timescaledb:
condition: service_healthy condition: service_healthy

View file

@ -11,6 +11,7 @@ services:
OPENDTU_PASSWORD: ${OPENDTU_PASSWORD} OPENDTU_PASSWORD: ${OPENDTU_PASSWORD}
TIMESCALEDB_ENABLED: ${TIMESCALEDB_ENABLED} TIMESCALEDB_ENABLED: ${TIMESCALEDB_ENABLED}
TZ: ${TZ} TZ: ${TZ}
LOG_LEVEL: ${LOG_LEVEL}
depends_on: depends_on:
timescaledb: timescaledb:
condition: service_healthy condition: service_healthy

11
docker/example.env Normal file
View file

@ -0,0 +1,11 @@
# OpenDTU
OPENDTU_ADDRESS="192.168.1.89:80"
OPENDTU_AUTH=false
OPENDTU_USERNAME=
OPENDTU_PASSWORD=
# OpenDTU Logger
DB_URL="host=timescaledb port=5432 user=postgres password=secret dbname=opendtu_logger sslmode=disable"
TIMESCALEDB_ENABLED=true
TZ="Europe/Amsterdam"
LOG_LEVEL=INFO"

View file

@ -3,10 +3,13 @@ OPENDTU_ADDRESS="192.168.1.89:80"
OPENDTU_AUTH=false OPENDTU_AUTH=false
OPENDTU_USERNAME= OPENDTU_USERNAME=
OPENDTU_PASSWORD= OPENDTU_PASSWORD=
# OpenDTU Logger # OpenDTU Logger
DB_URL="host=timescaledb port=5432 user=postgres password=secret dbname=opendtu_logger sslmode=disable" DB_URL="host=timescaledb port=5432 user=postgres password=secret dbname=opendtu_logger sslmode=disable"
TIMESCALEDB_ENABLED=true TIMESCALEDB_ENABLED=true
TZ="Europe/Amsterdam" TZ="Europe/Amsterdam"
LOG_LEVEL=INFO"
# Database configuration # Database configuration
PG_USER=postgres PG_USER=postgres
PG_PASSWORD= PG_PASSWORD=

View file

@ -232,6 +232,7 @@ func loadConfig() Config {
config.TimescaleDB = timescaleDB config.TimescaleDB = timescaleDB
} }
config.TZ = os.Getenv("TZ") config.TZ = os.Getenv("TZ")
config.LogLevel = os.Getenv("LOG_LEVEL")
} }
_, err = time.LoadLocation(config.TZ) _, err = time.LoadLocation(config.TZ)
if err != nil { if err != nil {

View file

@ -23,6 +23,8 @@ Environment="OPENDTU_PASSWORD=your_super_secret_password"
Environment="DB_URL=host=localhost port=5432 user=postgres password=secret dbname=dtu sslmode=disable" Environment="DB_URL=host=localhost port=5432 user=postgres password=secret dbname=dtu sslmode=disable"
Environment="TIMESCALEDB_ENABLED=true" Environment="TIMESCALEDB_ENABLED=true"
Environment="TZ=Europe/Amsterdam" Environment="TZ=Europe/Amsterdam"
Environment="LOG_LEVEL=INFO"
WorkingDirectory=/opt/opendtu-logger/ WorkingDirectory=/opt/opendtu-logger/
ExecStart=/opt/opendtu-logger/opendtu-logger ExecStart=/opt/opendtu-logger/opendtu-logger