MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/cloud-sql-proxy / runShutdownCmd

Function runShutdownCmd

cmd/root.go:412–433  ·  view source on GitHub ↗
(c *cobra.Command, _ []string)

Source from the content-addressed store, hash-verified

410}
411
412func runShutdownCmd(c *cobra.Command, _ []string) error {
413 p, _ := c.Flags().GetString(adminPortFlag)
414 addr := fmt.Sprintf("http://127.0.0.1:%v/quitquitquit", p)
415 c.SilenceUsage = true
416
417 req, err := http.NewRequestWithContext(c.Context(), "POST", addr, nil)
418 if err != nil {
419 return fmt.Errorf("failed to create shutdown request: %w", err)
420 }
421
422 resp, err := http.DefaultClient.Do(req)
423 if err != nil {
424 return fmt.Errorf("failed to send shutdown request: %w", err)
425 }
426 defer resp.Body.Close()
427
428 if resp.StatusCode != http.StatusOK {
429 return fmt.Errorf("shutdown request failed: status code %v, %v", resp.StatusCode, resp.Status)
430 }
431
432 return nil
433}
434
435const envPrefix = "CSQL_PROXY"
436

Callers

nothing calls this directly

Calls 2

ErrorfMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected