Repository navigation
Expand file tree
/
Copy pathmain.go
More file actions
67 lines (55 loc) · 2.09 KB
/
Copy pathmain.go
File metadata and controls
67 lines (55 loc) · 2.09 KB
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
66
67
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/securitylog"
"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}).WithFields(securitylog.Fields(
"STARTUP",
"glitchtip_configuration",
"GLITCHTIP_DSN",
securitylog.OutcomeFailure,
securitylog.ProcessPrincipal("entitlements-api-go"),
)).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)
// Bundle config startup failure - SEC-MON-REQ-1 compliance (EOI-5 process_status, EOI-11 warnings_or_errors)
logger.Log.WithFields(logrus.Fields{"error": err}).WithFields(securitylog.Fields(
"STARTUP",
"bundle_configuration",
config.GetConfig().Options.GetString(config.Keys.BundleInfoYaml),
securitylog.OutcomeFailure,
securitylog.ProcessPrincipal("entitlements-api-go"),
)).Fatal("Error reading bundles.yml")
}
// Load the paid-feature catalog once at startup (used only for is_trial). Depends on
// the bundle info loaded above; fails safe to is_trial=false if the catalog is
// unavailable, so it never blocks startup.
controllers.InitPaidFeatures()
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)
}