mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-18 02:48:40 +00:00
log/sockstatlog: only start once; don't copy ticker
Signed-off-by: Will Norris <will@tailscale.com>
This commit is contained in:
parent
8c4adde083
commit
6ef2105a8e
@ -1448,10 +1448,6 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
|
|||||||
|
|
||||||
b.e.SetNetInfoCallback(b.setNetInfo)
|
b.e.SetNetInfoCallback(b.setNetInfo)
|
||||||
|
|
||||||
if b.sockstatLogger != nil {
|
|
||||||
b.sockstatLogger.Start()
|
|
||||||
}
|
|
||||||
|
|
||||||
blid := b.backendLogID
|
blid := b.backendLogID
|
||||||
b.logf("Backend: logs: be:%v fe:%v", blid, opts.FrontendLogID)
|
b.logf("Backend: logs: be:%v fe:%v", blid, opts.FrontendLogID)
|
||||||
b.send(ipn.Notify{BackendLogID: &blid})
|
b.send(ipn.Notify{BackendLogID: &blid})
|
||||||
|
@ -26,7 +26,7 @@ type Logger struct {
|
|||||||
ctx context.Context
|
ctx context.Context
|
||||||
cancelFn context.CancelFunc
|
cancelFn context.CancelFunc
|
||||||
|
|
||||||
ticker time.Ticker
|
ticker *time.Ticker
|
||||||
logf logger.Logf
|
logf logger.Logf
|
||||||
logbuffer *filch.Filch
|
logbuffer *filch.Filch
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ type event struct {
|
|||||||
|
|
||||||
// NewLogger returns a new Logger that will store stats in logdir.
|
// NewLogger returns a new Logger that will store stats in logdir.
|
||||||
// On platforms that do not support sockstat logging, a nil Logger will be returned.
|
// On platforms that do not support sockstat logging, a nil Logger will be returned.
|
||||||
// The returned Logger is not yet running.
|
// The returned Logger must be shut down with Shutdown when it is no longer needed.
|
||||||
func NewLogger(logdir string, logf logger.Logf) (*Logger, error) {
|
func NewLogger(logdir string, logf logger.Logf) (*Logger, error) {
|
||||||
if !sockstats.IsAvailable {
|
if !sockstats.IsAvailable {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@ -68,17 +68,17 @@ func NewLogger(logdir string, logf logger.Logf) (*Logger, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
return &Logger{
|
logger := &Logger{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
cancelFn: cancel,
|
cancelFn: cancel,
|
||||||
ticker: *time.NewTicker(pollPeriod),
|
ticker: time.NewTicker(pollPeriod),
|
||||||
logf: logf,
|
logf: logf,
|
||||||
logbuffer: filch,
|
logbuffer: filch,
|
||||||
}, nil
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (l *Logger) Start() {
|
go logger.poll()
|
||||||
go l.poll()
|
|
||||||
|
return logger, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// poll fetches the current socket stats at the configured time interval,
|
// poll fetches the current socket stats at the configured time interval,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user