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) {
|
||||
defer wg.Done()
|
||||
|
||||
hub := sentry.CurrentHub().Clone()
|
||||
defer hub.Flush(10 * time.Second)
|
||||
defer wg.Done()
|
||||
|
||||
temperature.Initialize()
|
||||
|
||||
|
@ -181,16 +180,15 @@ func main() {
|
|||
wg.Add(1)
|
||||
go shutdownHTTP(ctxb, wg, srv)
|
||||
shutdown()
|
||||
nc.Close()
|
||||
wg.Wait()
|
||||
nc.Close()
|
||||
log.Print("Shutdown complete")
|
||||
}
|
||||
|
||||
func shutdownHTTP(ctx context.Context, wg *sync.WaitGroup, srv *http.Server) {
|
||||
defer wg.Done()
|
||||
|
||||
hub := sentry.CurrentHub().Clone()
|
||||
defer hub.Flush(10 * time.Second)
|
||||
defer wg.Done()
|
||||
|
||||
ctx2, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||
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) {
|
||||
defer wg.Done()
|
||||
defer p.hub.Flush(10 * time.Second)
|
||||
defer wg.Done()
|
||||
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
|
||||
|
|
Loading…
Reference in a new issue