Improve config (json) file creation

This commit is contained in:
Tobias Reisinger 2024-03-28 03:19:15 +01:00
parent 1d4e9efa15
commit 525eb21649
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
6 changed files with 91 additions and 84 deletions

1
.env
View file

@ -1 +0,0 @@
DATABASE_URL="sqlite://emgauwa-dev.sqlite"

19
.gitignore vendored
View file

@ -1,15 +1,8 @@
/target/
/tests/testing/
/tests/testing_bak/
/tests/testing_latest/
emgauwa-*.sqlite
emgauwa-*.sqlite-*
emgauwa-*.json
# Added by cargo
/target /target
/.env
/api.http /api.http
/emgauwa-*.sqlite
/emgauwa-*.sqlite-*
/emgauwa-*.json

View file

@ -1,5 +1,13 @@
ifneq (,$(wildcard ./.env))
include .env
export
endif
DATABASE_URL ?= sqlite://emgauwa-dev.sqlite
export DATABASE_URL
sqlx: sqlx:
cargo sqlx database drop cargo sqlx database drop -y
cargo sqlx database create cargo sqlx database create
cargo sqlx migrate run cargo sqlx migrate run
cargo sqlx prepare --workspace cargo sqlx prepare --workspace
@ -7,9 +15,16 @@ sqlx:
build-rpi: build-rpi:
cross build --target arm-unknown-linux-gnueabihf cross build --target arm-unknown-linux-gnueabihf
emgauwa-%.json: config/emgauwa-%.pkl config/lib/%.pkl config/lib/common.pkl emgauwa-%.json: config/emgauwa-%.pkl config/lib/%.pkl config/lib/common.pkl $(wildcard .env)
pkl eval -f json -o $@ $< pkl eval -f json -o $@ $<
configs: configs:
$(MAKE) emgauwa-core.json $(MAKE) emgauwa-core.json
$(MAKE) emgauwa-controller.json $(MAKE) emgauwa-controller.json
clean:
rm -f emgauwa-controller.json
rm -f emgauwa-controller.sqlite
rm -f emgauwa-core.json
rm -f emgauwa-core.sqlite
rm -f emgauwa-dev.sqlite

View file

@ -1,71 +1,71 @@
amends "./lib/controller.pkl" amends "./lib/controller.pkl"
server { server {
host = "127.0.0.1" host = "127.0.0.1"
port = 4419 port = 4419
} }
database = "sqlite://emgauwa-controller.sqlite" database = "sqlite://emgauwa-controller.sqlite"
permissions { permissions {
user = read("env:USER") user = read("env:USER")
group = read("env:USER") group = read("env:USER")
} }
logging { logging {
level = "DEBUG" level = read?("env:LOGGING_LEVEL") ?? "DEBUG"
file = "stdout" file = "stdout"
} }
relays { relays {
new { new {
driver = "gpio" driver = "gpio"
pin = 5 pin = 5
inverted = true inverted = true
} }
new { new {
driver = "gpio" driver = "gpio"
pin = 4 pin = 4
inverted = true inverted = true
} }
new { new {
driver = "gpio" driver = "gpio"
pin = 3 pin = 3
inverted = true inverted = true
} }
new { new {
driver = "gpio" driver = "gpio"
pin = 2 pin = 2
inverted = true inverted = true
} }
new { new {
driver = "gpio" driver = "gpio"
pin = 1 pin = 1
inverted = true inverted = true
} }
new { new {
driver = "gpio" driver = "gpio"
pin = 0 pin = 0
inverted = true inverted = true
} }
new { new {
driver = "gpio" driver = "gpio"
pin = 16 pin = 16
inverted = true inverted = true
} }
new { new {
driver = "gpio" driver = "gpio"
pin = 15 pin = 15
inverted = true inverted = true
} }
new { new {
driver = "piface" driver = "piface"
pin = 1 pin = 1
inverted = false inverted = false
} }
new { new {
driver = "piface" driver = "piface"
pin = 0 pin = 0
inverted = false inverted = false
} }
} }

View file

@ -1,18 +1,18 @@
amends "./lib/core.pkl" amends "./lib/core.pkl"
server { server {
host = "127.0.0.1" host = "127.0.0.1"
port = 4419 port = 4419
} }
database = "sqlite://emgauwa-core.sqlite" database = "sqlite://emgauwa-core.sqlite"
permissions { permissions {
user = read("env:USER") user = read("env:USER")
group = read("env:USER") group = read("env:USER")
} }
logging { logging {
level = "DEBUG" level = read?("env:LOGGING_LEVEL") ?? "DEBUG"
file = "stdout" file = "stdout"
} }

View file

@ -1,15 +1,15 @@
class ServerConfig { class ServerConfig {
host: String host: String
port: UInt16 port: UInt16
} }
/// Set to a user and a group to drop privileges to after binding to the port /// Set to a user and a group to drop privileges to after binding to the port
class PermissionsConfig { class PermissionsConfig {
user: String user: String
group: String group: String
} }
class LoggingConfig { class LoggingConfig {
level: String level: "TRACE"|"DEBUG"|"INFO"|"WARN"|"ERROR"|"FATAL"
file: String file: String
} }