Healthcheck moved to HTTP control server
This commit is contained in:
@@ -3,12 +3,11 @@ package cli
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"net"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/params"
|
||||
"github.com/qdm12/gluetun/internal/provider"
|
||||
@@ -40,13 +39,20 @@ func ClientKey(args []string) error {
|
||||
}
|
||||
|
||||
func HealthCheck() error {
|
||||
ips, err := net.LookupIP("github.com")
|
||||
client := &http.Client{Timeout: time.Second}
|
||||
response, err := client.Get("http://localhost:8000/health")
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot resolve github.com (%s)", err)
|
||||
} else if len(ips) == 0 {
|
||||
return fmt.Errorf("resolved no IP addresses for github.com")
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
defer response.Body.Close()
|
||||
if response.StatusCode == http.StatusOK {
|
||||
return nil
|
||||
}
|
||||
b, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return fmt.Errorf("HTTP status code %s with message: %s", response.Status, string(b))
|
||||
}
|
||||
|
||||
func OpenvpnConfig() error {
|
||||
|
||||
Reference in New Issue
Block a user