(ctx context.Context, cfg Config)
| 51 | var notificationTemplateIDRegex = regexp.MustCompile(`notifications\?disabled=([a-f0-9-]+)`) |
| 52 | |
| 53 | func (s *Server) Start(ctx context.Context, cfg Config) error { |
| 54 | s.hostAddress = cfg.HostAddress |
| 55 | s.smtpPort = cfg.SMTPPort |
| 56 | s.apiPort = cfg.APIPort |
| 57 | s.logger = cfg.Logger |
| 58 | |
| 59 | s.smtpServer = smtpmocklib.New(smtpmocklib.ConfigurationAttr{ |
| 60 | LogToStdout: false, |
| 61 | LogServerActivity: true, |
| 62 | HostAddress: s.hostAddress, |
| 63 | PortNumber: s.smtpPort, |
| 64 | }) |
| 65 | if err := s.smtpServer.Start(); err != nil { |
| 66 | return xerrors.Errorf("start SMTP server: %w", err) |
| 67 | } |
| 68 | s.smtpPort = s.smtpServer.PortNumber() |
| 69 | |
| 70 | if err := s.startAPIServer(ctx); err != nil { |
| 71 | _ = s.smtpServer.Stop() |
| 72 | return xerrors.Errorf("start API server: %w", err) |
| 73 | } |
| 74 | |
| 75 | return nil |
| 76 | } |
| 77 | |
| 78 | func (s *Server) Stop() error { |
| 79 | var httpErr, smtpErr error |
nothing calls this directly
no test coverage detected