mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-04 14:03:35 +01:00
Add debug
This commit is contained in:
parent
9db1932664
commit
40551099b3
@ -1,13 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/netbirdio/netbird/client/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +120,35 @@ func (s *Server) Start() error {
|
||||
ctx, cancel := context.WithCancel(s.rootCtx)
|
||||
s.actCancel = cancel
|
||||
|
||||
go func() {
|
||||
ticker := time.NewTicker(30 * time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
if statusResp, err := s.Status(ctx, &proto.StatusRequest{GetFullPeerStatus: true}); err != nil {
|
||||
log.Infof("Error getting status: %v", err)
|
||||
} else if statusResp.FullStatus != nil {
|
||||
log.Infof("Status --------")
|
||||
for _, peer := range statusResp.FullStatus.Peers {
|
||||
log.Infof("[Peer Connection] Name: %s, IP: %s, Key: %s, Connection Status: %s, Relayed: %v, RelayedAddress: %v, Last WireGuard Handshake: %v",
|
||||
peer.Fqdn,
|
||||
peer.IP,
|
||||
peer.PubKey,
|
||||
peer.ConnStatus,
|
||||
peer.Relayed,
|
||||
peer.RelayAddress,
|
||||
peer.LastWireguardHandshake.AsTime().Format("15:04:05"),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// if configuration exists, we just start connections. if is new config we skip and set status NeedsLogin
|
||||
// on failure we return error to retry
|
||||
config, err := internal.UpdateConfig(s.latestConfigInput)
|
||||
|
Loading…
Reference in New Issue
Block a user