Move server shutdown into group.go.
This commit is contained in:
1 parent
184bd30077
commit
c860fb96a3
2 files changed
+7
-6
No files matched your search
+6
-2
@@ -701,8 +701,12 @@ func kickall(g *Group, message string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) Shutdown(message string) {
|
func Shutdown(message string) {
|
||||||
kickall(g, message)
|
Range(func(g *Group) bool {
|
||||||
|
g.SetLocked(true, message)
|
||||||
|
kickall(g, message)
|
||||||
|
return true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type warner interface {
|
type warner interface {
|
||||||
|
|||||||
@@ -70,10 +70,7 @@ func Serve(address string, dataDir string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.RegisterOnShutdown(func() {
|
s.RegisterOnShutdown(func() {
|
||||||
group.Range(func(g *group.Group) bool {
|
group.Shutdown("server is shutting down")
|
||||||
go g.Shutdown("server is shutting down")
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
server.Store(s)
|
server.Store(s)
|
||||||
|
|||||||
Reference in new issue
Block a user