Add a command line flag to set the port and default to 8080
This commit is contained in:
parent
e809c29b73
commit
4a293eb912
2 changed files with 5 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -9,6 +10,8 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var port = flag.Int("port", 8080, "The port to host on")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
fmt.Println("Initialising...")
|
fmt.Println("Initialising...")
|
||||||
|
@ -29,7 +32,7 @@ func main() {
|
||||||
|
|
||||||
// Listen and serve the http requests
|
// Listen and serve the http requests
|
||||||
fmt.Println("Serving HTTP")
|
fmt.Println("Serving HTTP")
|
||||||
if err := http.ListenAndServe(":80", router); err != nil {
|
if err := http.ListenAndServe(fmt.Sprintf(":%d", *port), router); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,4 @@ services:
|
||||||
rove-server:
|
rove-server:
|
||||||
build: .
|
build: .
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:8080"
|
Loading…
Add table
Reference in a new issue