-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
42 lines (38 loc) · 1006 Bytes
/
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
package main
import (
"fmt"
"os"
"time"
"beryju.io/imagik/cmd"
"github.com/getsentry/sentry-go"
log "github.com/sirupsen/logrus"
)
var buildCommit string
func main() {
dsn := "https://[email protected]/7"
if edsn, enabled := os.LookupEnv("SENTRY_DSN"); enabled {
dsn = edsn
}
env := "default-env"
if eenv, enabled := os.LookupEnv("SENTRY_ENVIRONMENT"); enabled {
env = eenv
}
l := log.WithField("component", "imagik.root.sentry")
err := sentry.Init(sentry.ClientOptions{
Dsn: dsn,
AttachStacktrace: true,
TracesSampleRate: 1,
EnableTracing: true,
Environment: env,
Debug: true,
DebugWriter: l.WriterLevel(log.DebugLevel),
Release: fmt.Sprintf("imagik@%s", buildCommit),
})
if err != nil {
log.WithError(err).Warning("failed to init sentry")
}
log.WithField("commit", buildCommit).Info("imagik starting.")
defer sentry.Flush(time.Second * 5)
defer sentry.Recover()
cmd.Execute()
}