diff --git a/cmd/pax/cmd_server.go b/cmd/pax/cmd_server.go index 7bbc8bb..7e0b92f 100644 --- a/cmd/pax/cmd_server.go +++ b/cmd/pax/cmd_server.go @@ -57,6 +57,7 @@ func (s *serverCmd) Execute([]string) error { GRPCListenAddr: opt.GRPCListenAddr, SpanToken: opt.Token, SpanCollectionID: opt.CollectionID, + HTTPHost: opt.HTTPHost, }) c := make(chan os.Signal, 2) diff --git a/cmd/pax/main.go b/cmd/pax/main.go index f17674a..4340629 100644 --- a/cmd/pax/main.go +++ b/cmd/pax/main.go @@ -6,14 +6,14 @@ import ( ) var opt struct { - DB string `long:"db" default:"pax.db" description:"pax database" required:"yes"` - HTTPListenAddr string `long:"http" default:":4500" description:"HTTP listen address" required:"yes"` - GRPCListenAddr string `long:"grpc" default:":4501" description:"gRPC listen address" required:"yes"` - Token string `long:"token" env:"SPAN_API_TOKEN" description:"Span API Token" required:"yes"` - CollectionID string `long:"collection" description:"Span Collection ID for PAX counters" default:"17dlb1hl0l800a"` - - Server serverCmd `command:"server" description:"start server"` - Fetch fetchCmd `command:"fetch" description:"fetch historical data"` + DB string `long:"db" default:"pax.db" description:"pax database" required:"yes"` + HTTPListenAddr string `long:"http" default:":4500" description:"HTTP listen address" required:"yes"` + GRPCListenAddr string `long:"grpc" default:":4501" description:"gRPC listen address" required:"yes"` + Token string `long:"token" env:"SPAN_API_TOKEN" description:"Span API Token" required:"yes"` + CollectionID string `long:"collection" description:"Span Collection ID for PAX counters" default:"17dlb1hl0l800a"` + HTTPHost string `long:"host" default:"http://localhost:4500" description:"HTTP (external) URL" required:"yes"` + Server serverCmd `command:"server" description:"start server"` + Fetch fetchCmd `command:"fetch" description:"fetch historical data"` } func main() { diff --git a/pkg/server/http.go b/pkg/server/http.go index 7e0fdcd..193a32a 100644 --- a/pkg/server/http.go +++ b/pkg/server/http.go @@ -50,8 +50,8 @@ func (s *Server) startHTTP() error { httpMux := http.NewServeMux() // TODO: Use the proper external address here. Either "http://localhost:4500" (dev) or https://pax.lab5e.com (production) - - gotileserver.RegisterHandler(httpMux, "http://localhost:4500") + log.Printf("Registering map tile server with external address %s", s.config.HTTPHost) + gotileserver.RegisterHandler(httpMux, s.config.HTTPHost) mux.PathPrefix("/map").Handler(httpMux) mux.PathPrefix("/").Handler(http.FileServer(http.FS(frontendFS))) diff --git a/pkg/server/server.go b/pkg/server/server.go index 7086959..c049fd4 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -25,6 +25,7 @@ type Config struct { GRPCListenAddr string SpanToken string SpanCollectionID string + HTTPHost string } // Create and start server instance.