Add configurable port

This commit is contained in:
Ivan Danyliuk 2018-07-04 21:57:57 +02:00
parent 4f5b2fe38a
commit bb06410908
No known key found for this signature in database
GPG Key ID: 97ED33CE024E1DBF
2 changed files with 4 additions and 4 deletions

View File

@ -9,6 +9,7 @@ import (
)
func main() {
bind := flag.String("bind", ":20002", "Port to bind to")
iterations := flag.Int("i", 600, "Graph layout iterations to run (0 = auto, buggy)")
flag.Parse()
@ -39,7 +40,7 @@ func main() {
ws.updateGraph(data)
ws.updatePropagationData(plog)
log.Printf("Starting web server...")
startWeb(ws)
log.Printf("Starting web server on %s...", *bind)
startWeb(ws, *bind)
select {}
}

3
web.go
View File

@ -9,8 +9,7 @@ import (
"runtime"
)
func startWeb(ws *WSServer) {
port := ":20002"
func startWeb(ws *WSServer, port string) {
go func() {
fs := http.FileServer(http.Dir("web"))
http.Handle("/", noCacheMiddleware(fs))