a6e081e5cd
inject and print version at startup for all services * inject and print version * coverage
34 lines
522 B
Go
34 lines
522 B
Go
// cmd/healthcheck/main.go
|
|
package main
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
"os"
|
|
|
|
"queryorchestration/internal/serviceconfig/build"
|
|
)
|
|
|
|
func main() {
|
|
// Print version information before any environment checks
|
|
build.PrintVersionInfo("healthcheck")
|
|
|
|
err := check()
|
|
if err != nil {
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func check() error {
|
|
resp, err := http.Get("http://localhost:8080/health")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
if resp.StatusCode != 200 {
|
|
return errors.New("Status code not OK")
|
|
}
|
|
return nil
|
|
}
|