Commit 8d58571d authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Create webserver structure in main thread.

Avoids a race.
parent 71022f4b
...@@ -41,19 +41,19 @@ func webserver() { ...@@ -41,19 +41,19 @@ func webserver() {
http.HandleFunc("/public-groups.json", publicHandler) http.HandleFunc("/public-groups.json", publicHandler)
http.HandleFunc("/stats", statsHandler) http.HandleFunc("/stats", statsHandler)
go func() { server = &http.Server{
server = &http.Server{ Addr: httpAddr,
Addr: httpAddr, ReadHeaderTimeout: 60 * time.Second,
ReadHeaderTimeout: 60 * time.Second, IdleTimeout: 120 * time.Second,
IdleTimeout: 120 * time.Second, }
server.RegisterOnShutdown(func() {
groups.mu.Lock()
defer groups.mu.Unlock()
for _, g := range groups.groups {
go g.shutdown("server is shutting down")
} }
server.RegisterOnShutdown(func() { })
groups.mu.Lock() go func() {
defer groups.mu.Unlock()
for _, g := range groups.groups {
go g.shutdown("server is shutting down")
}
})
var err error var err error
err = server.ListenAndServeTLS( err = server.ListenAndServeTLS(
filepath.Join(dataDir, "cert.pem"), filepath.Join(dataDir, "cert.pem"),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment