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:
parent
340ec841fe
commit
6acfb580dc
7 changed files with 37 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue