Change deferred function call order
This commit is contained in:
parent
df6355e91a
commit
b876de55f9
2 changed files with 4 additions and 6 deletions
|
@ -23,10 +23,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func mainLoop(ctx context.Context, wg *sync.WaitGroup, js nats.JetStream, config *controllers.ControllerConfig) {
|
func mainLoop(ctx context.Context, wg *sync.WaitGroup, js nats.JetStream, config *controllers.ControllerConfig) {
|
||||||
defer wg.Done()
|
|
||||||
|
|
||||||
hub := sentry.CurrentHub().Clone()
|
hub := sentry.CurrentHub().Clone()
|
||||||
defer hub.Flush(10 * time.Second)
|
defer hub.Flush(10 * time.Second)
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
temperature.Initialize()
|
temperature.Initialize()
|
||||||
|
|
||||||
|
@ -181,16 +180,15 @@ func main() {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go shutdownHTTP(ctxb, wg, srv)
|
go shutdownHTTP(ctxb, wg, srv)
|
||||||
shutdown()
|
shutdown()
|
||||||
nc.Close()
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
nc.Close()
|
||||||
log.Print("Shutdown complete")
|
log.Print("Shutdown complete")
|
||||||
}
|
}
|
||||||
|
|
||||||
func shutdownHTTP(ctx context.Context, wg *sync.WaitGroup, srv *http.Server) {
|
func shutdownHTTP(ctx context.Context, wg *sync.WaitGroup, srv *http.Server) {
|
||||||
defer wg.Done()
|
|
||||||
|
|
||||||
hub := sentry.CurrentHub().Clone()
|
hub := sentry.CurrentHub().Clone()
|
||||||
defer hub.Flush(10 * time.Second)
|
defer hub.Flush(10 * time.Second)
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
ctx2, cancel := context.WithTimeout(ctx, 10*time.Second)
|
ctx2, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
|
@ -62,8 +62,8 @@ func NewChamberController(name string, config ControllerConfig, chTemp <-chan te
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ChamberController) Run(ctx context.Context, wg *sync.WaitGroup) {
|
func (p *ChamberController) Run(ctx context.Context, wg *sync.WaitGroup) {
|
||||||
defer wg.Done()
|
|
||||||
defer p.hub.Flush(10 * time.Second)
|
defer p.hub.Flush(10 * time.Second)
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
ticker := time.NewTicker(1 * time.Second)
|
ticker := time.NewTicker(1 * time.Second)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue