From cadf6cb8519a4c50cae6fbafd7196cb6637d86e5 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Fri, 13 Jan 2017 08:53:01 -0700 Subject: [PATCH] Added http-transport to SERVER call * fixed index out of range error when --http-transport provided without value. --- cmd/tile38-server/main.go | 13 +++++-------- controller/controller.go | 2 ++ controller/stats.go | 1 + 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/tile38-server/main.go b/cmd/tile38-server/main.go index 7e6d1345..def83116 100644 --- a/cmd/tile38-server/main.go +++ b/cmd/tile38-server/main.go @@ -109,7 +109,7 @@ func main() { case "--dev", "-dev": devMode = true continue - case "--http-transport": + case "--http-transport", "-http-transport": i++ if i < len(os.Args) { switch strings.ToLower(os.Args[i]) { @@ -120,6 +120,8 @@ func main() { } continue } + fmt.Fprintf(os.Stderr, "http-transport must be 'yes' or 'no'\n") + os.Exit(1) } nargs = append(nargs, os.Args[i]) } @@ -153,11 +155,6 @@ func main() { gitsha = "" } - httpTransportEnabled := "Enabled" - if !httpTransport { - httpTransportEnabled = "Disabled" - } - // _____ _ _ ___ ___ // |_ _|_| |___|_ | . | // | | | | | -_|_ | . | @@ -168,10 +165,10 @@ func main() { | | | |____ | _ | Tile38 %s%s %d bit (%s/%s) | | | %sPort: %d, PID: %d - |____ | _ | HTTP & WebSocket transports: %s + |____ | _ | | | | |_______|_______| tile38.com -`+"\n", core.Version, gitsha, strconv.IntSize, runtime.GOARCH, runtime.GOOS, hostd, port, os.Getpid(), httpTransportEnabled) +`+"\n", core.Version, gitsha, strconv.IntSize, runtime.GOARCH, runtime.GOOS, hostd, port, os.Getpid()) if err := controller.ListenAndServe(host, port, dir, httpTransport); err != nil { log.Fatal(err) diff --git a/controller/controller.go b/controller/controller.go index 68b24142..6b2d68bc 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -84,6 +84,7 @@ type Controller struct { expires map[string]map[string]time.Time conns map[*server.Conn]bool started time.Time + http bool epc *endpoint.EndpointManager @@ -121,6 +122,7 @@ func ListenAndServeEx(host string, port int, dir string, ln *net.Listener, http started: time.Now(), conns: make(map[*server.Conn]bool), epc: endpoint.NewEndpointManager(), + http: http, } if err := os.MkdirAll(dir, 0700); err != nil { return err diff --git a/controller/stats.go b/controller/stats.go index ab2cab15..9a0864ce 100644 --- a/controller/stats.go +++ b/controller/stats.go @@ -81,6 +81,7 @@ func (c *Controller) cmdServer(msg *server.Message) (res string, err error) { m["following"] = fmt.Sprintf("%s:%d", c.config.FollowHost, c.config.FollowPort) m["caught_up"] = c.fcup } + m["http_transport"] = c.http m["pid"] = os.Getpid() m["aof_size"] = c.aofsz m["num_collections"] = c.cols.Len()