| 95 | } |
| 96 | |
| 97 | public async close(): Promise<any> { |
| 98 | if (!this.applicationConfig) { |
| 99 | return; |
| 100 | } |
| 101 | const adapter = this.applicationConfig.getIoAdapter(); |
| 102 | if (!adapter) { |
| 103 | return; |
| 104 | } |
| 105 | const servers = this.socketsContainer.getAll(); |
| 106 | await Promise.all( |
| 107 | iterate(servers.values()) |
| 108 | .filter(({ server }) => server) |
| 109 | .map(async ({ server }) => adapter.close(server)), |
| 110 | ); |
| 111 | await (adapter as AbstractWsAdapter)?.dispose(); |
| 112 | |
| 113 | this.socketsContainer.clear(); |
| 114 | } |
| 115 | |
| 116 | private initializeAdapter() { |
| 117 | const forceCloseConnections = (this.appOptions as NestApplicationOptions) |