3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 10:42:52 +01:00

server: Close store properly, on shutdown

This commit is contained in:
Daniel Oaks 2016-09-05 19:39:16 +10:00
parent 6e96a175d6
commit 4cb196f50a

View File

@ -90,7 +90,6 @@ func NewServer(config *Config) *Server {
if err != nil {
log.Fatal(fmt.Sprintf("Failed to open datastore: %s", err.Error()))
}
defer db.Close()
server.store = *db
// load password manager
@ -237,13 +236,16 @@ func (server *Server) loadChannels() {
}
func (server *Server) Shutdown() {
server.db.Close()
//TODO(dan): Make sure we disallow new nicks
for _, client := range server.clients.byNick {
client.Notice("Server is shutting down")
}
if err := server.db.Close(); err != nil {
Log.error.Println("Server.Shutdown: error:", err)
Log.error.Println("Server.Shutdown db.Close: error:", err)
}
if err := server.store.Close(); err != nil {
Log.error.Println("Server.Shutdown store.Close: error:", err)
}
}