Added http-transport to SERVER call

* fixed index out of range error when --http-transport provided
  without value.
This commit is contained in:
Josh Baker 2017-01-13 08:53:01 -07:00
parent 23e846e9df
commit cadf6cb851
3 changed files with 8 additions and 8 deletions

View File

@ -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)

View File

@ -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

View File

@ -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()