mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-08 09:07:44 +00:00
ipn/ipnserver: move Windows local disk logging up to the parent process
To capture panics, log.Printf writes to os.Stderr, etc. Fixes #726
This commit is contained in:
parent
420838f90e
commit
ff7ddd9d20
@ -26,6 +26,7 @@
|
|||||||
"inet.af/netaddr"
|
"inet.af/netaddr"
|
||||||
"tailscale.com/control/controlclient"
|
"tailscale.com/control/controlclient"
|
||||||
"tailscale.com/ipn"
|
"tailscale.com/ipn"
|
||||||
|
"tailscale.com/log/filelogger"
|
||||||
"tailscale.com/logtail/backoff"
|
"tailscale.com/logtail/backoff"
|
||||||
"tailscale.com/net/netstat"
|
"tailscale.com/net/netstat"
|
||||||
"tailscale.com/safesocket"
|
"tailscale.com/safesocket"
|
||||||
@ -520,6 +521,11 @@ func Run(ctx context.Context, logf logger.Logf, logid string, getEngine func() (
|
|||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BabysitProc runs the current executable as a child process with the
|
||||||
|
// provided args, capturing its output, writing it to files, and
|
||||||
|
// restarting the process on any crashes.
|
||||||
|
//
|
||||||
|
// It's only currently (2020-10-29) used on Windows.
|
||||||
func BabysitProc(ctx context.Context, args []string, logf logger.Logf) {
|
func BabysitProc(ctx context.Context, args []string, logf logger.Logf) {
|
||||||
|
|
||||||
executable, err := os.Executable()
|
executable, err := os.Executable()
|
||||||
@ -527,6 +533,14 @@ func BabysitProc(ctx context.Context, args []string, logf logger.Logf) {
|
|||||||
panic("cannot determine executable: " + err.Error())
|
panic("cannot determine executable: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
if len(args) != 2 && args[0] != "/subproc" {
|
||||||
|
panic(fmt.Sprintf("unexpected arguments %q", args))
|
||||||
|
}
|
||||||
|
logID := args[1]
|
||||||
|
logf = filelogger.New("tailscale-service", logID, logf)
|
||||||
|
}
|
||||||
|
|
||||||
var proc struct {
|
var proc struct {
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
p *os.Process
|
p *os.Process
|
||||||
|
Loading…
x
Reference in New Issue
Block a user