Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

service: wait for the SCM to see an ended forwarder before starting it

shukieshahe76a15bf5fa4
diff --git a/cli/beacon/internal/endpoint/service/windows_scm.go b/cli/beacon/internal/endpoint/service/windows_scm.go
index 5f03f782..17827876 100644
--- a/cli/beacon/internal/endpoint/service/windows_scm.go
+++ b/cli/beacon/internal/endpoint/service/windows_scm.go
@@ -319,7 +319,16 @@ func stopAndWait(s *mgr.Service, name string, timeout time.Duration, terminateHu
if err := waitForServiceProcess(process, name, time.Now().Add(timeout), timeout); err != nil {
return errors.Join(stopErr, err)
}
- return nil
+ // The SCM learns of the exit on its own, a moment later. Until it has, the service still
+ // reads as pending, and a start issued now is refused as already running.
+ settle := time.Now().Add(timeout)
+ for time.Now().Before(settle) {
+ if status, err := s.Query(); err == nil && status.State == svc.Stopped {
+ return nil
+ }
+ time.Sleep(200 * time.Millisecond)
+ }
+ return errors.Join(stopErr, fmt.Errorf("the %s service's process was ended but the service never reported stopped", name))
}
if _, err := s.Control(svc.Stop); err != nil {