Igor Sirotin 987a9e8707
feat_: add Sentry panic reporting (#6054)
* feat_: report panics to sentry

* test_: sentry options, params and utils

* feat_: toggle sentry with centralized metrics

* test_: sentry init, report and close

* refactor_: rename public api to generic

* docs_: sentry

* fix_: typo in internal/sentry/README.md

Co-authored-by: osmaczko <33099791+osmaczko@users.noreply.github.com>

* fix_: linter

---------

Co-authored-by: osmaczko <33099791+osmaczko@users.noreply.github.com>
2024-11-25 12:13:47 +00:00

61 lines
1.3 KiB
Go

package main
import (
"flag"
stdlog "log"
"os"
"golang.org/x/crypto/ssh/terminal"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/cmd/status-backend/server"
"github.com/status-im/status-go/internal/sentry"
"github.com/status-im/status-go/internal/version"
"github.com/status-im/status-go/logutils"
)
var (
address = flag.String("address", "127.0.0.1:0", "host:port to listen")
logger = log.New("package", "status-go/cmd/status-backend")
)
func init() {
logSettings := logutils.LogSettings{
Enabled: true,
MobileSystem: false,
Level: "INFO",
Colorized: terminal.IsTerminal(int(os.Stdin.Fd())),
}
if err := logutils.OverrideRootLoggerWithConfig(logSettings); err != nil {
stdlog.Fatalf("failed to initialize log: %v", err)
}
}
func main() {
sentry.MustInit(
sentry.WithDefaultEnvironmentDSN(),
sentry.WithContext("status-backend", version.Version()),
)
defer sentry.Recover()
flag.Parse()
srv := server.NewServer()
srv.Setup()
err := srv.Listen(*address)
if err != nil {
logger.Error("failed to start server", "error", err)
return
}
log.Info("status-backend started",
"address", srv.Address(),
"version", version.Version(),
"gitCommit", version.GitCommit(),
)
srv.RegisterMobileAPI()
srv.Serve()
}