dynamic conf

This commit is contained in:
Bel LaPointe
2026-09-09 07:42:10 -07:00
parent 4b41ba6ff4
commit 709b7d46db
2 changed files with 33 additions and 9 deletions
+25 -2
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"time"
"gopkg.in/yaml.v2"
)
@@ -30,8 +31,8 @@ type (
}
)
func NewConfig() (Config, error) {
var c Config
func NewConfig() (*Config, error) {
c := &Config{}
fs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
fs.StringVar(&c.Cert.CRT, "crt", "", "path to .crt")
@@ -60,3 +61,25 @@ func NewConfig() (Config, error) {
return c, nil
}
func (c *Config) Start() {
go c.start()
}
func (c *Config) start() {
ch := time.NewTicker(30 * time.Second)
defer ch.Stop()
for range ch.C {
func() {
c2, err := NewConfig()
if err != nil {
return
}
if fmt.Sprintf("%+v", c.Domains) != fmt.Sprintf("%+v", c2.Domains) {
c.Domains = c2.Domains
}
}()
}
}