1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-04 21:35:23 +02:00

feat(cli): Add CLI flag for health-check (#1366)

This commit is contained in:
1138-4EB 2018-01-15 19:34:07 +01:00 committed by Anthony Lapenna
parent 340ec841fe
commit 6acfb580dc
7 changed files with 37 additions and 6 deletions

View file

@ -14,6 +14,7 @@ import (
"github.com/portainer/portainer/ldap"
"log"
"os"
)
func initCLI() *portainer.CLIFlags {
@ -171,6 +172,19 @@ func retrieveFirstEndpointFromDatabase(endpointService portainer.EndpointService
func main() {
flags := initCLI()
if *flags.CheckHealth {
statuscode, err := http.HealthCheck(*flags.Addr)
if err == nil {
if statuscode == 200 {
log.Println(*flags.Addr, ": Online - response:", statuscode)
os.Exit(0)
} else {
log.Fatal(*flags.Addr, ": Error - response:", statuscode)
}
}
log.Fatal("Connection error:", err.Error())
}
fileService := initFileService(*flags.Data)
store := initStore(*flags.Data)