Added support for environmental config values

Updated Go version to 1.20.0
This commit is contained in:
James Wells 2023-02-10 07:23:35 -08:00
parent 77c9399942
commit 4a9d4ceca8
Signed by: jwells
GPG key ID: 73196D10B8E65666
6 changed files with 23 additions and 6 deletions

View file

@ -9,6 +9,8 @@ import (
autorestart "github.com/slayer/autorestart"
env "github.com/caarlos0/env/v6"
fqdn "github.com/Showmax/go-fqdn"
gstructs "github.com/dragonheim/gagent/internal/gstructs"
@ -52,6 +54,12 @@ var (
* 10 Router not connected
*/
var environment struct {
Mode string `env:"GAGENT_MODE" envDefault:"setup"`
Port int `env:"PORT" envDefault:"3000"`
UUID string `env:"GAGENT_UUID" envDefault:""`
}
var config gstructs.GagentConfig
func main() {
@ -112,9 +120,15 @@ func main() {
func init() {
// var err error
autorestart.StartWatcher()
cfg := environment
if err := env.Parse(&cfg); err != nil {
log.Printf("%+v\n", err)
}
log.Printf("%+v\n", cfg)
filter := &logutils.LevelFilter{
Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"},
MinLevel: logutils.LogLevel("DEBUG"),