-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* healthcheck * Fix error message on exit
- Loading branch information
Showing
4 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"net/http" | ||
"os" | ||
"strings" | ||
) | ||
|
||
func main() { | ||
if err := run(); err != nil { | ||
fmt.Printf("Error: %v", err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func run() error { | ||
port, found := os.LookupEnv("ICC_PORT") | ||
if !found { | ||
port = "9007" | ||
} | ||
|
||
resp, err := http.Get("http://localhost:" + port + "/system/icc/health") | ||
if err != nil { | ||
return fmt.Errorf("sending request: %w", err) | ||
} | ||
|
||
if resp.StatusCode != 200 { | ||
return fmt.Errorf("health returned status %s", resp.Status) | ||
} | ||
|
||
body, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
return fmt.Errorf("reading response body: %w", err) | ||
} | ||
|
||
expect := `{"healthy":true}` | ||
got := strings.TrimSpace(string(body)) | ||
if got != expect { | ||
return fmt.Errorf("got `%s`, expected `%s`", body, expect) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters