commit d82f3eb39d9d6c6cc6e6908ec1851b34e0a3012f
parent ae65e3bdd49810eb502aaeb830831d6907c6938f
Author: ctucx <c@ctu.cx>
Date: Sun, 19 Jan 2020 13:13:41 +0100
parent ae65e3bdd49810eb502aaeb830831d6907c6938f
Author: ctucx <c@ctu.cx>
Date: Sun, 19 Jan 2020 13:13:41 +0100
build static binary, read configfile path and accesstoken from envVars
3 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/nim.cfg b/nim.cfg @@ -0,0 +1 @@ +--passL:"-static -no-pie"
diff --git a/src/backend_powermeter b/src/backend_powermeter Binary files differ.
diff --git a/src/smartied.nim b/src/smartied.nim @@ -1,19 +1,22 @@ -import asyncdispatch -import frontend_tcp -import frontend_ws -import frontend_http -import frontend_prometheus -import backend_powermeter -import backend_relayboard -import backend_lacrosse -import types -import modbus -import json -import vars -import util -import tables - -server = Server(config: parseJson(readFile("./config.json")).to(Config)) +import asyncdispatch, types, modbus, json, vars, util, tables, os +import frontend_tcp, frontend_ws, frontend_http, frontend_prometheus +import backend_powermeter, backend_relayboard, backend_lacrosse + +var configFile = "./config.json" + +if getEnv("CONFIG_PATH") != "": + configFile = getEnv("CONFIG_PATH") + +if not fileExists(configFile): + echo "Config file not found" + quit() + +server = Server(config: parseFile(configFile).to(Config)) + +if getEnv("ACCESS_TOKEN") != "": + server.config.accessToken = getEnv("ACCESS_TOKEN") + +echo server.config.accessToken proc main() {.async.} = initUtil()