Improve configuration
This commit is contained in:
parent
71498256f6
commit
ace4face5a
9 changed files with 66 additions and 51 deletions
|
@ -1,3 +1,3 @@
|
|||
#EMGAUWA_CONTROLLER_LOGGING_LEVEL=INFO
|
||||
#EMGAUWA_CONTROLLER__LOGGING__LEVEL=DEBUG
|
||||
|
||||
#EMGAUWA_CORE_LOGGING_LEVEL=INFO
|
||||
#EMGAUWA_CORE__LOGGING__LEVEL=DEBUG
|
||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,8 +1,10 @@
|
|||
/target
|
||||
/pkl-out
|
||||
|
||||
/.env
|
||||
/api.http
|
||||
|
||||
/emgauwa-*.sqlite
|
||||
/emgauwa-*.sqlite-*
|
||||
/emgauwa-*.json
|
||||
/emgauwa-*.json
|
||||
|
||||
|
|
13
Makefile
13
Makefile
|
@ -1,11 +1,3 @@
|
|||
ifneq (,$(wildcard ./.env))
|
||||
include .env
|
||||
export
|
||||
endif
|
||||
|
||||
DATABASE_URL ?= sqlite://emgauwa-dev.sqlite
|
||||
export DATABASE_URL
|
||||
|
||||
sqlx:
|
||||
cargo sqlx database drop -y
|
||||
cargo sqlx database create
|
||||
|
@ -15,13 +7,16 @@ sqlx:
|
|||
build-rpi:
|
||||
cross build --target arm-unknown-linux-gnueabihf
|
||||
|
||||
emgauwa-%.json: config/emgauwa-%.pkl config/lib/%.pkl config/lib/common.pkl $(wildcard .env)
|
||||
emgauwa-%.json: config/%.pkl config/lib/%.pkl
|
||||
pkl eval -f json -o $@ $<
|
||||
|
||||
configs:
|
||||
$(MAKE) emgauwa-core.json
|
||||
$(MAKE) emgauwa-controller.json
|
||||
|
||||
pkl-package:
|
||||
pkl project package config --output-path "./pkl-out"
|
||||
|
||||
clean:
|
||||
rm -f emgauwa-controller.json
|
||||
rm -f emgauwa-controller.sqlite
|
||||
|
|
8
config/PklProject
Normal file
8
config/PklProject
Normal file
|
@ -0,0 +1,8 @@
|
|||
amends "pkl:Project"
|
||||
|
||||
package {
|
||||
name = "emgauwa"
|
||||
baseUri = "package://emgauwa.app/pkl/\(name)"
|
||||
version = "0.1.0"
|
||||
packageZipUrl = "https://emgauwa.app/pkl/\(name)@\(version).zip"
|
||||
}
|
4
config/PklProject.deps.json
Normal file
4
config/PklProject.deps.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"resolvedDependencies": {}
|
||||
}
|
|
@ -13,59 +13,61 @@ permissions {
|
|||
}
|
||||
|
||||
logging {
|
||||
level = read?("env:EMGAUWA_CONTROLLER_LOGGING_LEVEL") ?? "DEBUG"
|
||||
level = "INFO"
|
||||
file = "stdout"
|
||||
}
|
||||
|
||||
relays {
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 24
|
||||
inverted = true
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 23
|
||||
inverted = true
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 22
|
||||
inverted = true
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 27
|
||||
inverted = true
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 18
|
||||
inverted = true
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 17
|
||||
inverted = true
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 15
|
||||
inverted = true
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 14
|
||||
pin = 0
|
||||
inverted = true
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 1
|
||||
inverted = true
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 2
|
||||
inverted = true
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 3
|
||||
inverted = true
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 4
|
||||
inverted = true
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 5
|
||||
inverted = true
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 10
|
||||
inverted = true
|
||||
pulse = 10
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 11
|
||||
inverted = true
|
||||
pulse = 10
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 20
|
||||
inverted = false
|
||||
}
|
||||
new {
|
||||
driver = "null"
|
||||
pin = 0
|
||||
pin = 21
|
||||
inverted = false
|
||||
}
|
||||
}
|
|
@ -13,6 +13,6 @@ permissions {
|
|||
}
|
||||
|
||||
logging {
|
||||
level = read?("env:EMGAUWA_CORE_LOGGING_LEVEL") ?? "DEBUG"
|
||||
level = "INFO"
|
||||
file = "stdout"
|
||||
}
|
|
@ -12,5 +12,6 @@ class RelayConfig {
|
|||
driver: "null"|"gpio"|"piface"
|
||||
pin: Number
|
||||
inverted: Boolean
|
||||
pulse: Number(this >= 0)|Null = null
|
||||
}
|
||||
relays: Listing<RelayConfig>
|
||||
|
|
|
@ -49,9 +49,12 @@ pub fn load<T>(config_name: &str, env_prefix: &str) -> Result<T, EmgauwaError>
|
|||
where
|
||||
for<'de> T: serde::Deserialize<'de>,
|
||||
{
|
||||
let etc_file =
|
||||
config::File::with_name(&format!("/etc/emgauwa/{}", config_name)).required(false);
|
||||
let local_file = config::File::with_name(&format!("./emgauwa-{}", config_name)).required(false);
|
||||
|
||||
config::Config::builder()
|
||||
.add_source(etc_file)
|
||||
.add_source(local_file)
|
||||
.add_source(
|
||||
config::Environment::with_prefix(&format!("EMGAUWA_{}", env_prefix))
|
||||
|
|
Loading…
Reference in a new issue