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
/.env
/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:
cargo sqlx database drop
cargo sqlx database drop -y
cargo sqlx database create
cargo sqlx migrate run
cargo sqlx prepare --workspace
@ -7,9 +15,16 @@ sqlx:
build-rpi:
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 $@ $<
configs:
$(MAKE) emgauwa-core.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"
server {
host = "127.0.0.1"
port = 4419
host = "127.0.0.1"
port = 4419
}
database = "sqlite://emgauwa-controller.sqlite"
permissions {
user = read("env:USER")
group = read("env:USER")
user = read("env:USER")
group = read("env:USER")
}
logging {
level = "DEBUG"
file = "stdout"
level = read?("env:LOGGING_LEVEL") ?? "DEBUG"
file = "stdout"
}
relays {
new {
driver = "gpio"
pin = 5
inverted = true
}
new {
driver = "gpio"
pin = 4
inverted = true
}
new {
driver = "gpio"
pin = 3
inverted = true
}
new {
driver = "gpio"
pin = 2
inverted = true
}
new {
driver = "gpio"
pin = 1
inverted = true
}
new {
driver = "gpio"
pin = 0
inverted = true
}
new {
driver = "gpio"
pin = 16
inverted = true
}
new {
driver = "gpio"
pin = 15
inverted = true
}
new {
driver = "piface"
pin = 1
inverted = false
}
new {
driver = "piface"
pin = 0
inverted = false
}
new {
driver = "gpio"
pin = 5
inverted = true
}
new {
driver = "gpio"
pin = 4
inverted = true
}
new {
driver = "gpio"
pin = 3
inverted = true
}
new {
driver = "gpio"
pin = 2
inverted = true
}
new {
driver = "gpio"
pin = 1
inverted = true
}
new {
driver = "gpio"
pin = 0
inverted = true
}
new {
driver = "gpio"
pin = 16
inverted = true
}
new {
driver = "gpio"
pin = 15
inverted = true
}
new {
driver = "piface"
pin = 1
inverted = false
}
new {
driver = "piface"
pin = 0
inverted = false
}
}

View file

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

View file

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