mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-05 07:01:01 +00:00
cmd/tailscaled, logtail: share link monitor from wgengine to logtail
Part of overall effort to clean up, unify, use link monitoring more, and make Tailscale quieter when all networks are down. This is especially bad on macOS where we can get killed for not being polite it seems. (But we should be polite in any case) Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
24fa616e73
commit
c0cdca6d06
@ -36,6 +36,7 @@ import (
|
|||||||
"tailscale.com/version"
|
"tailscale.com/version"
|
||||||
"tailscale.com/wgengine"
|
"tailscale.com/wgengine"
|
||||||
"tailscale.com/wgengine/magicsock"
|
"tailscale.com/wgengine/magicsock"
|
||||||
|
"tailscale.com/wgengine/monitor"
|
||||||
"tailscale.com/wgengine/netstack"
|
"tailscale.com/wgengine/netstack"
|
||||||
"tailscale.com/wgengine/router"
|
"tailscale.com/wgengine/router"
|
||||||
"tailscale.com/wgengine/tstun"
|
"tailscale.com/wgengine/tstun"
|
||||||
@ -195,6 +196,12 @@ func run() error {
|
|||||||
go runDebugServer(debugMux, args.debug)
|
go runDebugServer(debugMux, args.debug)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linkMon, err := monitor.New(logf)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("creating link monitor: %v", err)
|
||||||
|
}
|
||||||
|
pol.Logtail.SetLinkMonitor(linkMon)
|
||||||
|
|
||||||
var socksListener net.Listener
|
var socksListener net.Listener
|
||||||
if args.socksAddr != "" {
|
if args.socksAddr != "" {
|
||||||
var err error
|
var err error
|
||||||
@ -206,6 +213,7 @@ func run() error {
|
|||||||
|
|
||||||
conf := wgengine.Config{
|
conf := wgengine.Config{
|
||||||
ListenPort: args.port,
|
ListenPort: args.port,
|
||||||
|
LinkMonitor: linkMon,
|
||||||
}
|
}
|
||||||
if args.tunname == "userspace-networking" {
|
if args.tunname == "userspace-networking" {
|
||||||
conf.TUN = tstun.NewFakeTUN()
|
conf.TUN = tstun.NewFakeTUN()
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
|
|
||||||
"tailscale.com/logtail/backoff"
|
"tailscale.com/logtail/backoff"
|
||||||
tslogger "tailscale.com/types/logger"
|
tslogger "tailscale.com/types/logger"
|
||||||
|
"tailscale.com/wgengine/monitor"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultHost is the default host name to upload logs to when
|
// DefaultHost is the default host name to upload logs to when
|
||||||
@ -106,6 +107,7 @@ type Logger struct {
|
|||||||
url string
|
url string
|
||||||
lowMem bool
|
lowMem bool
|
||||||
skipClientTime bool
|
skipClientTime bool
|
||||||
|
linkMonitor *monitor.Mon
|
||||||
buffer Buffer
|
buffer Buffer
|
||||||
sent chan struct{} // signal to speed up drain
|
sent chan struct{} // signal to speed up drain
|
||||||
drainLogs <-chan struct{} // if non-nil, external signal to attempt a drain
|
drainLogs <-chan struct{} // if non-nil, external signal to attempt a drain
|
||||||
@ -128,6 +130,14 @@ func (l *Logger) SetVerbosityLevel(level int) {
|
|||||||
l.stderrLevel = level
|
l.stderrLevel = level
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetLinkMonitor sets the optional the link monitor.
|
||||||
|
//
|
||||||
|
// It should not be changed concurrently with log writes and should
|
||||||
|
// only be set once.
|
||||||
|
func (l *Logger) SetLinkMonitor(lm *monitor.Mon) {
|
||||||
|
l.linkMonitor = lm
|
||||||
|
}
|
||||||
|
|
||||||
// Shutdown gracefully shuts down the logger while completing any
|
// Shutdown gracefully shuts down the logger while completing any
|
||||||
// remaining uploads.
|
// remaining uploads.
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user