summaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorache <ache@ache.one>2021-05-16 04:12:17 +0200
committerache <ache@ache.one>2021-05-16 04:13:28 +0200
commitcb41e56c7b7f28616c9c1960c4e97fa6de655df5 (patch)
tree32cb10b50b0d6a42779c3e61b97423870789bf1e /server.go
parentLog moving (diff)
Deal with hostnames
Diffstat (limited to 'server.go')
-rw-r--r--server.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/server.go b/server.go
index 4bb2435..820a21a 100644
--- a/server.go
+++ b/server.go
@@ -7,6 +7,7 @@ import (
"os"
"io"
"html/template"
+ "sync"
"flag"
"path"
"net/url"
@@ -489,9 +490,23 @@ func main() {
return
}
- fmt.Println("Launch server on port:", port)
http.HandleFunc("/", handleMethod)
- log.Fatal(http.ListenAndServe(":" + strconv.Itoa(port), nil))
+ if len(config.Config.Hostnames) == 0 {
+ fmt.Println("Error: No hostnames precised\nEmpty will be set", port)
+ config.Config.Hostnames = []string{""}
+ }
+
+ var wg sync.WaitGroup
+ wg.Add(len(config.Config.Hostnames))
+
+ for _, host := range config.Config.Hostnames {
+ go func(host string) {
+ defer wg.Done()
+ fmt.Println("Launch server listen on " + host + ":" + strconv.Itoa(port))
+ log.Fatal(http.ListenAndServe(host + ":" + strconv.Itoa(port), nil))
+ }(host)
+ }
+ wg.Wait()
fmt.Println("Bye bye")
}