refactor smtp

This commit is contained in:
Aine
2022-11-10 13:26:12 +02:00
parent e6722dd5e8
commit 307aca7f23
11 changed files with 395 additions and 376 deletions

View File

@@ -20,9 +20,9 @@ import (
)
var (
mxb *bot.Bot
smtpserv *smtp.Server
log *logger.Logger
mxb *bot.Bot
smtpm *smtp.Manager
log *logger.Logger
)
func main() {
@@ -45,7 +45,7 @@ func main() {
go startBot(cfg.StatusMsg)
if err := smtpserv.Start(); err != nil {
if err := smtpm.Start(); err != nil {
//nolint:gocritic
log.Fatal("SMTP server crashed: %v", err)
}
@@ -96,7 +96,7 @@ func initBot(cfg *config.Config) {
}
func initSMTP(cfg *config.Config) {
smtpserv = smtp.NewServer(&smtp.Config{
smtpm = smtp.NewManager(&smtp.Config{
Domains: cfg.Domains,
Port: cfg.Port,
TLSCert: cfg.TLS.Cert,
@@ -132,7 +132,7 @@ func startBot(statusMsg string) {
func shutdown() {
log.Info("Shutting down...")
smtpserv.Stop()
smtpm.Stop()
mxb.Stop()
sentry.Flush(5 * time.Second)