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:
parent
6e96a175d6
commit
4cb196f50a
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user