-
Notifications
You must be signed in to change notification settings - Fork 21
/
main.go
48 lines (37 loc) · 1.27 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
package main
import (
"os"
"time"
"github.com/RedHatInsights/entitlements-api-go/config"
"github.com/RedHatInsights/entitlements-api-go/controllers"
"github.com/RedHatInsights/entitlements-api-go/logger"
"github.com/RedHatInsights/entitlements-api-go/server"
"github.com/sirupsen/logrus"
"github.com/getsentry/sentry-go"
)
func main() {
// Init the logger first thing
logger.InitLogger()
var dsn string = os.Getenv("GLITCHTIP_DSN")
if dsn != "" {
err := sentry.Init(sentry.ClientOptions{
Dsn: dsn,
})
if err != nil {
logger.Log.WithFields(logrus.Fields{"error": err}).Error("Error loading Sentry SDK with GLITCHTIP_DSN")
} else {
logger.Log.Info("Sentry SDK initialization using Glitchtip was successful!")
}
} else {
logger.Log.Info("GLITCHTIP_DSN was not set, skipping Glitchtip initialization.")
}
// init config here
if err := controllers.SetBundleInfo(config.GetConfig().Options.GetString(config.Keys.BundleInfoYaml)); err != nil {
sentry.CaptureException(err)
logger.Log.WithFields(logrus.Fields{"error": err}).Fatal("Error reading bundles.yml")
}
server.Launch()
// Flush buffered events before the program terminates.
// Set the timeout to the maximum duration the program can afford to wait.
defer sentry.Flush(2 * time.Second)
}