Use reloaded configuration in mainloop
This commit is contained in:
parent
52b1108798
commit
5ecc4ba27a
1 changed files with 6 additions and 0 deletions
|
@ -35,10 +35,13 @@ func mainLoop(ctx context.Context, wg *sync.WaitGroup, js nats.JetStream) {
|
||||||
// Controller
|
// Controller
|
||||||
config := configuration.Global()
|
config := configuration.Global()
|
||||||
ctrl := controllers.NewChamberController(config)
|
ctrl := controllers.NewChamberController(config)
|
||||||
|
|
||||||
|
chConfigChange := make(chan configuration.Configuration, 1)
|
||||||
chn := configuration.NewChangeNotifier()
|
chn := configuration.NewChangeNotifier()
|
||||||
viper.OnConfigChange(chn.OnConfigChange)
|
viper.OnConfigChange(chn.OnConfigChange)
|
||||||
|
|
||||||
// Configuration updates
|
// Configuration updates
|
||||||
|
chn.Subscribe(chConfigChange)
|
||||||
chn.Subscribe(temperature.ConfigUpdate)
|
chn.Subscribe(temperature.ConfigUpdate)
|
||||||
chn.Subscribe(ctrl.ConfigUpdates)
|
chn.Subscribe(ctrl.ConfigUpdates)
|
||||||
//chn.Subscribe(display.ConfiguUpdate)
|
//chn.Subscribe(display.ConfiguUpdate)
|
||||||
|
@ -129,6 +132,9 @@ func mainLoop(ctx context.Context, wg *sync.WaitGroup, js nats.JetStream) {
|
||||||
ingest.AddState(state)
|
ingest.AddState(state)
|
||||||
//display.SetState(state)
|
//display.SetState(state)
|
||||||
|
|
||||||
|
case c := <-chConfigChange:
|
||||||
|
config = c
|
||||||
|
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue