MCPcopy Index your code
hub / github.com/coder/envbox / WaitForManager

Function WaitForManager

sysboxutil/manager.go:16–46  ·  view source on GitHub ↗

WaitForManager waits for the sysbox-mgr to startup.

(ctx context.Context)

Source from the content-addressed store, hash-verified

14
15// WaitForManager waits for the sysbox-mgr to startup.
16func WaitForManager(ctx context.Context) error {
17 fs := xunix.GetFS(ctx)
18
19 _, err := fs.Stat(ManagerSocketPath)
20 if err == nil {
21 return nil
22 }
23
24 const (
25 period = time.Second
26 )
27
28 t := time.NewTicker(period)
29 defer t.Stop()
30
31 for {
32 select {
33 case <-ctx.Done():
34 return ctx.Err()
35 case <-t.C:
36 _, err := fs.Stat(ManagerSocketPath)
37 if err != nil {
38 if !xerrors.Is(err, os.ErrNotExist) {
39 return xerrors.Errorf("unexpected stat err %s: %w", ManagerSocketPath, err)
40 }
41 continue
42 }
43 return nil
44 }
45 }
46}

Callers 1

dockerCmdFunction · 0.92

Calls 3

GetFSFunction · 0.92
StopMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected