forked from mailhog/MailHog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
61 lines (54 loc) · 1.32 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"flag"
"os"
"github.com/ian-kent/go-log/log"
gotcha "github.com/ian-kent/gotcha/app"
"github.com/mailhog/MailHog-Server/api"
cfgapi "github.com/mailhog/MailHog-Server/config"
"github.com/mailhog/MailHog-Server/smtp"
"github.com/mailhog/MailHog-UI/assets"
cfgui "github.com/mailhog/MailHog-UI/config"
"github.com/mailhog/MailHog-UI/web"
"github.com/mailhog/http"
)
var apiconf *cfgapi.Config
var uiconf *cfgui.Config
var exitCh chan int
func configure() {
cfgapi.RegisterFlags()
cfgui.RegisterFlags()
flag.Parse()
apiconf = cfgapi.Configure()
uiconf = cfgui.Configure()
}
func main() {
configure()
exitCh = make(chan int)
if uiconf.UIBindAddr == apiconf.APIBindAddr {
cb := func(app *gotcha.App) {
web.CreateWeb(uiconf, app)
api.CreateAPIv1(apiconf, app)
api.CreateAPIv2(apiconf, app)
}
go http.Listen(uiconf.UIBindAddr, assets.Asset, exitCh, cb)
} else {
cb1 := func(app *gotcha.App) {
api.CreateAPIv1(apiconf, app)
api.CreateAPIv2(apiconf, app)
}
cb2 := func(app *gotcha.App) {
web.CreateWeb(uiconf, app)
}
go http.Listen(apiconf.APIBindAddr, assets.Asset, exitCh, cb1)
go http.Listen(uiconf.UIBindAddr, assets.Asset, exitCh, cb2)
}
go smtp.Listen(apiconf, exitCh)
for {
select {
case <-exitCh:
log.Printf("Received exit signal")
os.Exit(0)
}
}
}