Created
March 7, 2017 09:00
-
-
Save hatorikibble/df44945f9fa48423daa12a153fcf3a71 to your computer and use it in GitHub Desktop.
healthchecker in golang
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
package main | |
import ( | |
"flag" | |
"fmt" | |
"net/http" | |
"os" | |
) | |
func main() { | |
port := flag.String("port", "80", "port to check") | |
ip := flag.String("ip", "127.0.0.1", "ip address to check") | |
path := flag.String("path", "/health", "path to check") | |
flag.Parse() | |
resp, err := http.Get(fmt.Sprintf("http://%s:%s/%s",*ip,*port,*path)) | |
if err != nil || resp.StatusCode != 200 { | |
os.Exit(1) | |
} | |
os.Exit(0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment