MCPcopy Index your code
hub / github.com/coder/coder / syncPing

Method syncPing

cli/sync_ping.go:11–42  ·  view source on GitHub ↗
(socketPath *string)

Source from the content-addressed store, hash-verified

9)
10
11func (*RootCmd) syncPing(socketPath *string) *serpent.Command {
12 cmd := &serpent.Command{
13 Use: "ping",
14 Short: "Test agent socket connectivity and health",
15 Long: "Test connectivity to the local Coder agent socket to verify the agent is running and responsive. Useful for troubleshooting startup issues or verifying the agent is accessible before running other sync commands.",
16 Handler: func(i *serpent.Invocation) error {
17 ctx := i.Context()
18
19 opts := []agentsocket.Option{}
20 if *socketPath != "" {
21 opts = append(opts, agentsocket.WithPath(*socketPath))
22 }
23
24 client, err := agentsocket.NewClient(ctx, opts...)
25 if err != nil {
26 return xerrors.Errorf("connect to agent socket: %w", err)
27 }
28 defer client.Close()
29
30 err = client.Ping(ctx)
31 if err != nil {
32 return xerrors.Errorf("ping failed: %w", err)
33 }
34
35 cliui.Info(i.Stdout, "Success")
36
37 return nil
38 },
39 }
40
41 return cmd
42}

Callers 1

syncCommandMethod · 0.95

Calls 7

CloseMethod · 0.95
PingMethod · 0.95
WithPathFunction · 0.92
NewClientFunction · 0.92
InfoFunction · 0.92
ContextMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected