File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -396,13 +396,17 @@ class Server {
396
396
res . sendStatus ( 200 )
397
397
}
398
398
399
+ /**
400
+ * Gracefully stop server
401
+ * Stops watcher and socket server
402
+ */
399
403
async stop ( ) {
400
404
Logger . info ( '=== Stopping Server ===' )
401
405
await this . watcher . close ( )
402
406
Logger . info ( 'Watcher Closed' )
403
407
404
408
return new Promise ( ( resolve ) => {
405
- this . server . close ( ( err ) => {
409
+ SocketAuthority . close ( ( err ) => {
406
410
if ( err ) {
407
411
Logger . error ( 'Failed to close server' , err )
408
412
} else {
Original file line number Diff line number Diff line change @@ -73,6 +73,20 @@ class SocketAuthority {
73
73
}
74
74
}
75
75
76
+ /**
77
+ * Closes the Socket.IO server and disconnect all clients
78
+ *
79
+ * @param {Function } callback
80
+ */
81
+ close ( callback ) {
82
+ Logger . info ( '[SocketAuthority] Shutting down' )
83
+ // This will close all open socket connections, and also close the underlying http server
84
+ if ( this . io )
85
+ this . io . close ( callback )
86
+ else
87
+ callback ( )
88
+ }
89
+
76
90
initialize ( Server ) {
77
91
this . Server = Server
78
92
You can’t perform that action at this time.
0 commit comments