diff --git a/app/reaction.go b/app/reaction.go index 3f82bc4..f662b72 100644 --- a/app/reaction.go +++ b/app/reaction.go @@ -180,9 +180,6 @@ var wgActions sync.WaitGroup var db *gob.Encoder func Main() { - sigs := make(chan os.Signal, 1) - signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) - confFilename := flag.String("c", "", "configuration file. see an example at https://framagit.org/ppom/reaction/-/blob/main/reaction.yml") flag.Parse() @@ -191,8 +188,13 @@ func Main() { os.Exit(2) } - conf, localdb := parseConf(*confFilename) - db = localdb + conf := parseConf(*confFilename) + db = conf.updateFromDB() + + // Ready to start + + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) stopStreams = make(chan bool) stopActions = make(chan bool) diff --git a/app/conf.go b/app/startup.go similarity index 98% rename from app/conf.go rename to app/startup.go index 8f7d91a..5eddb0f 100644 --- a/app/conf.go +++ b/app/startup.go @@ -19,6 +19,9 @@ type Conf struct { Streams map[string]*Stream `yaml:"streams"` } +// Stream, Filter & Action structures must never be copied. +// They're always referenced through pointers + type Stream struct { name string `yaml:"-"` @@ -248,7 +251,6 @@ func (c *Conf) updateFromDB() *gob.Encoder { func parseConf(filename string) (*Conf, *gob.Encoder) { data, err := os.ReadFile(filename) - if err != nil { log.Fatalln("FATAL Failed to read configuration file:", err) } @@ -260,7 +262,5 @@ func parseConf(filename string) (*Conf, *gob.Encoder) { } conf.setup() - enc := conf.updateFromDB() - - return &conf, enc + return &conf }