Skip to content

Commit

Permalink
Merge pull request #386 from nyaruka/fix_shutdown_order
Browse files Browse the repository at this point in the history
Fix cloudwatch service stopping before tasks are stopped
  • Loading branch information
rowanseymour authored Dec 16, 2024
2 parents 2007107 + 3a1e4b9 commit a568f9a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/jmoiron/sqlx v1.4.0
github.com/lib/pq v1.10.9
github.com/nyaruka/ezconf v0.3.0
github.com/nyaruka/gocommon v1.60.4
github.com/nyaruka/gocommon v1.60.5
github.com/nyaruka/goflow v0.226.0
github.com/nyaruka/null/v3 v3.0.0
github.com/nyaruka/redisx v0.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ github.com/naoina/toml v0.1.1 h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8=
github.com/naoina/toml v0.1.1/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E=
github.com/nyaruka/ezconf v0.3.0 h1:kGvJqVN8AHowb4HdaHAviJ0Z3yI5Pyekp1WqibFEaGk=
github.com/nyaruka/ezconf v0.3.0/go.mod h1:89GUW6EPRNLIxT7lC4LWnjWTgZeQwRoX7lBmc8ralAU=
github.com/nyaruka/gocommon v1.60.4 h1:QpnSJailgaXpfjFjjuKTy/4NufgfmGfdFGib8khXm9o=
github.com/nyaruka/gocommon v1.60.4/go.mod h1:kFJuOq8COneV7ssfK6xgCMJ8gP8fQifLQnNXBnE4YL0=
github.com/nyaruka/gocommon v1.60.5 h1:V10rosGzVArRspilfbi65TyHBZzjLQbwmaBeicr2Drw=
github.com/nyaruka/gocommon v1.60.5/go.mod h1:kFJuOq8COneV7ssfK6xgCMJ8gP8fQifLQnNXBnE4YL0=
github.com/nyaruka/goflow v0.226.0 h1:mVJBy1ojDSWdnPx/Y/YPflcKIMgmXjM3oC6VVCRTBo4=
github.com/nyaruka/goflow v0.226.0/go.mod h1:spXtSWgS7dusHIfUFCvJGjSMc7d4FX9Abl6S7tg49ks=
github.com/nyaruka/null/v2 v2.0.3 h1:rdmMRQyVzrOF3Jff/gpU/7BDR9mQX0lcLl4yImsA3kw=
Expand Down
10 changes: 5 additions & 5 deletions mailroom.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (mr *Mailroom) Start() error {
log.Info("cloudwatch ok")
}

mr.rt.CW.StartQueue(mr.wg, time.Second*3)
mr.rt.CW.StartQueue(time.Second * 3)

// init our foremen and start it
mr.handlerForeman.Start()
Expand All @@ -167,16 +167,16 @@ func (mr *Mailroom) Stop() error {
mr.batchForeman.Stop()
mr.throttledForeman.Stop()

mr.rt.CW.StopQueue()

close(mr.quit)
close(mr.quit) // tell workers and crons to stop
mr.cancel()

// stop our web server
mr.webserver.Stop()

mr.wg.Wait()

// now that all tasks are finished, stop services they depend on
mr.rt.CW.StopQueue()

log.Info("mailroom stopped")
return nil
}
Expand Down

0 comments on commit a568f9a

Please sign in to comment.