|
|
@ -26,6 +26,7 @@ import (
|
|
|
|
"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
|
|
|
|