Skip to content

Commit

Permalink
close all function
Browse files Browse the repository at this point in the history
  • Loading branch information
henrod committed May 10, 2019
1 parent b92161d commit 812e4fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ func Start() {

logger.Log.Warn("server is stopping...")

session.CloseAll()
shutdownModules()
shutdownComponents()
}
Expand Down
12 changes: 12 additions & 0 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ func OnSessionClose(f func(s *Session)) {
SessionCloseCallbacks = append(SessionCloseCallbacks, f)
}

// CloseAll calls Close on all sessions
func CloseAll() {
// TODO: check if frontend?
logger.Log.Debug("closing all sessions, %d sessions", SessionCount)
sessionsByID.Range(func(_, value interface{}) bool {
s := value.(*Session)
s.Close()
return true
})
logger.Log.Debug("finished closing sessions")
}

func (s *Session) updateEncodedData() error {
var b []byte
b, err := json.Marshal(s.data)
Expand Down

0 comments on commit 812e4fe

Please sign in to comment.