Add a command line flag to set the port and default to 8080

This commit is contained in:
Marc Di Luzio 2020-05-29 22:45:17 +01:00
parent e809c29b73
commit 4a293eb912
2 changed files with 5 additions and 2 deletions

View file

@ -1,6 +1,7 @@
package main
import (
"flag"
"fmt"
"log"
"net/http"
@ -9,6 +10,8 @@ import (
"syscall"
)
var port = flag.Int("port", 8080, "The port to host on")
func main() {
fmt.Println("Initialising...")
@ -29,7 +32,7 @@ func main() {
// Listen and serve the http requests
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)
}
}

View file

@ -3,4 +3,4 @@ services:
rove-server:
build: .
ports:
- "80:80"
- "80:8080"