light refacto
This commit is contained in:
parent
3499cfd6c8
commit
4c86f37b70
@ -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)
|
||||
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user