cmd/tailscaled: run as a service on Windows

Updates #1232
This commit is contained in:
Brad Fitzpatrick
2021-02-05 08:46:12 -08:00
parent 7529b74018
commit 6099ecf7f4
3 changed files with 87 additions and 0 deletions

View File

@@ -132,6 +132,16 @@ func run() error {
pol.Shutdown(ctx)
}()
if isWindowsService() {
// Run the IPN server from the Windows service manager.
log.Printf("Running service...")
if err := runWindowsService(pol); err != nil {
log.Printf("runservice: %v", err)
}
log.Printf("Service ended.")
return nil
}
var logf logger.Logf = log.Printf
if v, _ := strconv.ParseBool(os.Getenv("TS_DEBUG_MEMORY")); v {
logf = logger.RusagePrefixLog(logf)