From d951256b1c1aa5ce19161de1f7632dcbd51b977b Mon Sep 17 00:00:00 2001 From: Jesse Crocker Date: Mon, 15 Apr 2019 12:29:15 -0600 Subject: [PATCH 1/2] Add option to choose a listening port --- maputnik.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/maputnik.go b/maputnik.go index c371fba4..611e025c 100644 --- a/maputnik.go +++ b/maputnik.go @@ -27,6 +27,11 @@ func main() { Name: "watch", Usage: "Notify web client about JSON style file changes", }, + cli.IntFlag{ + Name: "port", + Value: 8000, + Usage: "TCP port to listen on", + }, } app.Action = func(c *cli.Context) error { @@ -56,8 +61,8 @@ func main() { loggedRouter := handlers.LoggingHandler(os.Stdout, router) corsRouter := handlers.CORS(handlers.AllowedHeaders([]string{"Content-Type"}), handlers.AllowedMethods([]string{"GET", "PUT"}), handlers.AllowedOrigins([]string{"*"}), handlers.AllowCredentials())(loggedRouter) - fmt.Println("Exposing Maputnik on http://localhost:8000") - return http.ListenAndServe(":8000", corsRouter) + fmt.Printf("Exposing Maputnik on http://localhost:%d\n", c.Int("port")) + return http.ListenAndServe(fmt.Sprintf(":%d", c.Int("port")), corsRouter) } app.Run(os.Args) From 1ce2d59b9ba706385500679fc28e52f4a83f3ea6 Mon Sep 17 00:00:00 2001 From: Jesse Crocker Date: Wed, 4 Sep 2019 09:21:56 -0600 Subject: [PATCH 2/2] Add --port option to readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index b5d8d78d..b3f1c816 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,12 @@ use Maputnik. maputnik --watch --file basic-v9.json ``` +Choose a local port to listen on, instead of using the default port 8000. + +``` +maputnik --port 8001 +``` + ### API `maputnik` exposes the configured styles via a HTTP API.