mirror of
https://github.com/jech/galene.git
synced 2024-12-22 23:35:46 +01:00
Create webserver structure in main thread.
Avoids a race.
This commit is contained in:
parent
71022f4b58
commit
8d58571d4c
1 changed files with 12 additions and 12 deletions
24
webserver.go
24
webserver.go
|
@ -41,19 +41,19 @@ func webserver() {
|
|||
http.HandleFunc("/public-groups.json", publicHandler)
|
||||
http.HandleFunc("/stats", statsHandler)
|
||||
|
||||
go func() {
|
||||
server = &http.Server{
|
||||
Addr: httpAddr,
|
||||
ReadHeaderTimeout: 60 * time.Second,
|
||||
IdleTimeout: 120 * time.Second,
|
||||
server = &http.Server{
|
||||
Addr: httpAddr,
|
||||
ReadHeaderTimeout: 60 * 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()
|
||||
defer groups.mu.Unlock()
|
||||
for _, g := range groups.groups {
|
||||
go g.shutdown("server is shutting down")
|
||||
}
|
||||
})
|
||||
})
|
||||
go func() {
|
||||
var err error
|
||||
err = server.ListenAndServeTLS(
|
||||
filepath.Join(dataDir, "cert.pem"),
|
||||
|
|
Loading…
Reference in a new issue