mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-04 22:10:56 +01:00
42 lines
971 B
Go
42 lines
971 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
_ "net/http/pprof"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"github.com/netbirdio/netbird/client/cmd"
|
|
)
|
|
|
|
func main() {
|
|
// only if env is not set
|
|
if os.Getenv("NB_LOG_LEVEL") == "" {
|
|
if err := os.Setenv("NB_LOG_LEVEL", "debug"); err != nil {
|
|
log.Errorf("Failed setting log-level: %v", err)
|
|
}
|
|
}
|
|
if err := os.Setenv("NB_LOG_MAX_SIZE_MB", "100"); err != nil {
|
|
log.Errorf("Failed setting log-size: %v", err)
|
|
}
|
|
if err := os.Setenv("NB_WINDOWS_PANIC_LOG", filepath.Join(os.Getenv("ProgramData"), "netbird", "netbird.err")); err != nil {
|
|
log.Errorf("Failed setting panic log path: %v", err)
|
|
}
|
|
|
|
go startPprofServer()
|
|
|
|
if err := cmd.Execute(); err != nil {
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func startPprofServer() {
|
|
pprofAddr := "localhost:6969"
|
|
log.Infof("Starting pprof debugging server on %s", pprofAddr)
|
|
if err := http.ListenAndServe(pprofAddr, nil); err != nil {
|
|
log.Infof("pprof server failed: %v", err)
|
|
}
|
|
}
|