-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.go
65 lines (57 loc) · 1.37 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
62
63
64
65
package main
import (
"context"
"flag"
"net/http"
"os"
"os/signal"
"github.com/jasonrichardsmith/sentry/config"
_ "github.com/jasonrichardsmith/sentry/healthz"
_ "github.com/jasonrichardsmith/sentry/limits"
_ "github.com/jasonrichardsmith/sentry/nslabels"
_ "github.com/jasonrichardsmith/sentry/source"
_ "github.com/jasonrichardsmith/sentry/tags"
log "github.com/Sirupsen/logrus"
"github.com/jasonrichardsmith/sentry/mux"
"github.com/jasonrichardsmith/sentry/sentry"
)
var (
dev bool
)
func init() {
flag.BoolVar(&dev, "dev", false, "Run in dev mode no tls.")
}
func main() {
log.Info("Loading Config")
err := config.Load()
if err != nil {
log.Fatal(err)
}
log.Info("Config loaded")
log.Info(config.DefaultConfig)
s := mux.New(config.DefaultConfig)
var ss *http.Server
idleConnsClosed := make(chan struct{})
go func() {
sigint := make(chan os.Signal, 1)
signal.Notify(sigint, os.Interrupt)
<-sigint
if err := ss.Shutdown(context.Background()); err != nil {
log.Printf("Sentry server Shutdown: %v", err)
}
close(idleConnsClosed)
}()
if dev {
log.Info("Serving Sentry without TLS")
ss = sentry.NewSentryServerNoSSL(s)
log.Fatal(ss.ListenAndServe())
} else {
log.Info("Starting new Sentry Server")
ss, err = sentry.NewSentryServer(s)
if err != nil {
log.Fatal(err)
}
log.Fatal(ss.ListenAndServeTLS("", ""))
}
<-idleConnsClosed
}