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

Function isCoderRunning

scripts/develop/main.go:1441–1458  ·  view source on GitHub ↗
(ctx context.Context, baseURL string)

Source from the content-addressed store, hash-verified

1439}
1440
1441func isCoderRunning(ctx context.Context, baseURL string) bool {
1442 ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
1443 defer cancel()
1444 req, err := http.NewRequestWithContext(ctx, "GET", baseURL+"/api/v2/buildinfo", nil)
1445 if err != nil {
1446 return false
1447 }
1448 resp, err := http.DefaultClient.Do(req)
1449 if err != nil {
1450 return false
1451 }
1452 defer resp.Body.Close()
1453 var info struct{ Version string }
1454 if err := json.NewDecoder(resp.Body).Decode(&info); err != nil {
1455 return false
1456 }
1457 return info.Version != ""
1458}
1459
1460// shellBool returns "1" for true and "0" for false (shell convention).
1461func shellBool(b bool) string { //nolint:revive // trivial bool-to-string helper

Callers 1

preflightFunction · 0.85

Calls 2

DoMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected