package maddy import ( "io" "github.com/foxcpp/maddy/config" "github.com/foxcpp/maddy/log" // Import packages for side-effect of module registration. _ "github.com/foxcpp/maddy/auth/external" _ "github.com/foxcpp/maddy/auth/pam" _ "github.com/foxcpp/maddy/auth/shadow" _ "github.com/foxcpp/maddy/check/dkim" _ "github.com/foxcpp/maddy/check/dns" _ "github.com/foxcpp/maddy/check/dnsbl" _ "github.com/foxcpp/maddy/check/spf" _ "github.com/foxcpp/maddy/endpoint/imap" _ "github.com/foxcpp/maddy/endpoint/smtp" _ "github.com/foxcpp/maddy/modify" _ "github.com/foxcpp/maddy/modify/dkim" _ "github.com/foxcpp/maddy/storage/sql" _ "github.com/foxcpp/maddy/target/queue" _ "github.com/foxcpp/maddy/target/remote" _ "github.com/foxcpp/maddy/target/smtp_downstream" ) func Start(cfg []config.Node) error { globals := config.NewMap(nil, &config.Node{Children: cfg}) globals.String("hostname", false, false, "", nil) globals.String("autogenerated_msg_domain", false, false, "", nil) globals.Custom("tls", false, false, nil, config.TLSDirective, nil) globals.Bool("storage_perdomain", false, false, nil) globals.Bool("auth_perdomain", false, false, nil) globals.StringList("auth_domains", false, false, nil, nil) globals.Custom("log", false, false, defaultLogOutput, logOutput, &log.DefaultLogger.Out) globals.Bool("debug", false, log.DefaultLogger.Debug, &log.DefaultLogger.Debug) globals.AllowUnknown() unknown, err := globals.Process() if err != nil { return err } defer log.DefaultLogger.Out.Close() insts, err := instancesFromConfig(globals.Values, unknown) if err != nil { return err } handleSignals() for _, inst := range insts { if closer, ok := inst.(io.Closer); ok { if err := closer.Close(); err != nil { log.Printf("module %s (%s) close failed: %v", inst.Name(), inst.InstanceName(), err) } } } return nil }