diff options
Diffstat (limited to 'cmd_windows.go')
| -rw-r--r-- | cmd_windows.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/cmd_windows.go b/cmd_windows.go index 4d7df37..da26684 100644 --- a/cmd_windows.go +++ b/cmd_windows.go @@ -93,6 +93,27 @@ func run() { logInfo("watcher: monitoring for changes ...") + // Heartbeat goroutine to detect disconnects + go func() { + ticker := time.NewTicker(10 * time.Second) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + msg := &ProtocolMessage{Type: "ping"} + data, _ := EncodeMessage(msg) + data = append(data, '\n') + if _, err := conn.Write(data); err != nil { + logErrorf("heartbeat failed: %v", err) + conn.Close() + return + } + } + } + }() + if !watchLoop(ctx, conn, watcher, manifest, stack) { conn.Close() continue |
