Skip to content

Commit

Permalink
Add JS docs for server stop
Browse files Browse the repository at this point in the history
  • Loading branch information
advplyr committed Dec 28, 2023
1 parent 21d0d43 commit 9a634e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion server/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class Server {
await this.stop()
Logger.info('Server stopped. Exiting.')
} else {
Logger.info('SIGINT (Ctrl+C) received again. Exiting immediately.')
Logger.info('SIGINT (Ctrl+C) received again. Exiting immediately.')
}
process.exit(0)
})
Expand Down Expand Up @@ -395,6 +395,10 @@ class Server {
res.sendStatus(200)
}

/**
* Gracefully stop server
* Stops watcher and socket server
*/
async stop() {
Logger.info('=== Stopping Server ===')
await this.watcher.close()
Expand Down
7 changes: 6 additions & 1 deletion server/SocketAuthority.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,15 @@ class SocketAuthority {
}
}

/**
* Closes the Socket.IO server and disconnect all clients
*
* @param {Function} callback
*/
close(callback) {
Logger.info('[SocketAuthority] Shutting down')
// This will close all open socket connections, and also close the underlying http server
if (this.io)
if (this.io)
this.io.close(callback)
else
callback()
Expand Down

0 comments on commit 9a634e0

Please sign in to comment.