Skip to content

Commit

Permalink
Add optional session drain
Browse files Browse the repository at this point in the history
  • Loading branch information
rsafonseca committed Sep 30, 2023
1 parent b12ce00 commit 6fefaba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,13 @@ func Start() {
logger.Log.Warn("the app will shutdown in a few seconds")
case s := <-sg:
logger.Log.Warn("got signal: ", s, ", shutting down...")
if app.config.GetBool("pitaya.session.drain") {
logger.Log.Info("Session drain is enabled, draining all sessions before shutting down")
for session.SessionCount > 0 {
logger.Log.Infof("Waiting for all sessions to finish: %d sessions remaining...", session.SessionCount)
time.Sleep(5 * time.Second)
}
}
close(app.dieChan)
}

Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func (c *Config) fillDefaultValues() {
"pitaya.conn.ratelimiting.interval": "1s",
"pitaya.conn.ratelimiting.forcedisable": false,
"pitaya.session.unique": true,
"pitaya.session.drain": false,
"pitaya.worker.concurrency": 1,
"pitaya.worker.redis.pool": "10",
"pitaya.worker.redis.url": "localhost:6379",
Expand Down

0 comments on commit 6fefaba

Please sign in to comment.