diff options
Diffstat (limited to 'services/mailer/mailer.go')
-rw-r--r-- | services/mailer/mailer.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/services/mailer/mailer.go b/services/mailer/mailer.go index 5aeda9ed79..ee4721d438 100644 --- a/services/mailer/mailer.go +++ b/services/mailer/mailer.go @@ -401,7 +401,9 @@ func NewContext(ctx context.Context) { Sender = &smtpSender{} } - mailQueue = queue.CreateSimpleQueue("mail", func(items ...*Message) []*Message { + subjectTemplates, bodyTemplates = templates.Mailer(ctx) + + mailQueue = queue.CreateSimpleQueue(graceful.GetManager().ShutdownContext(), "mail", func(items ...*Message) []*Message { for _, msg := range items { gomailMsg := msg.ToMessage() log.Trace("New e-mail sending request %s: %s", gomailMsg.GetHeader("To"), msg.Info) @@ -413,10 +415,10 @@ func NewContext(ctx context.Context) { } return nil }) - - go graceful.GetManager().RunWithShutdownFns(mailQueue.Run) - - subjectTemplates, bodyTemplates = templates.Mailer(ctx) + if mailQueue == nil { + log.Fatal("Unable to create mail queue") + } + go graceful.GetManager().RunWithCancel(mailQueue) } // SendAsync send mail asynchronously |