aboutsummaryrefslogtreecommitdiff
path: root/cmd/web/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/web/main.go')
-rw-r--r--cmd/web/main.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/cmd/web/main.go b/cmd/web/main.go
index c799624..6db58d9 100644
--- a/cmd/web/main.go
+++ b/cmd/web/main.go
@@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"log"
+ "net"
"net/http"
"os"
"strconv"
@@ -67,15 +68,11 @@ func main() {
http.FileServer(http.FS(embeddedStatic)))
r.HandleFunc("/", a.HandleIndex)
- s := http.Server{
- Handler: r,
- Addr: Listen,
- }
-
- go startBrowser()
+ s := http.Server{Handler: r}
for i := 0; i < 5; i++ {
- err = s.ListenAndServe()
+ l, err := net.Listen("tcp", Listen)
+
if err != nil {
Logger.Printf("Encountered: %s", err)
@@ -89,8 +86,14 @@ func main() {
Listen = fmt.Sprintf("%s:%d", parts[0], port)
Logger.Printf("Trying: %s", Listen)
- s.Addr = Listen
+ continue
}
+ startBrowser("http://localhost" + Listen)
+
+ err = s.Serve(l)
+ if err != nil {
+ panic(err)
+ }
}
}