Wait for weaveDNS HTTP to be running before sending it names

This adds a no-op endpoint to the HTTP API at `/status`. The script
simply tries this until it succeeds or gets bored.
This commit is contained in:
Michael Bridgen committed 2014-11-26 14:18:26 +00:00
1 parent 6a076d05b0
commit b3d19d6e9d
2 files changed
+21

No files matched your search

+10
View File
@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"github.com/miekg/dns"
"io"
"log"
"net"
"net/http"
@@ -26,6 +27,15 @@ func httpErrorAndLog(level *log.Logger, w http.ResponseWriter, msg string,
}
func ListenHttp(domain string, db Zone, port int) {
http.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
} else {
io.WriteString(w, "ok")
}
})
http.HandleFunc("/name/", func(w http.ResponseWriter, r *http.Request) {
reqError := func(msg string, logmsg string, logargs ...interface{}) {