| 124 | * Call this during graceful shutdown. |
| 125 | */ |
| 126 | export async function shutdownSocketIOAdapter(): Promise<void> { |
| 127 | const closePromises: Promise<void>[] = [] |
| 128 | |
| 129 | if (adapterPubClient) { |
| 130 | closePromises.push( |
| 131 | adapterPubClient.quit().then(() => { |
| 132 | logger.info('Redis adapter pub client closed') |
| 133 | adapterPubClient = null |
| 134 | }) |
| 135 | ) |
| 136 | } |
| 137 | |
| 138 | if (adapterSubClient) { |
| 139 | closePromises.push( |
| 140 | adapterSubClient.quit().then(() => { |
| 141 | logger.info('Redis adapter sub client closed') |
| 142 | adapterSubClient = null |
| 143 | }) |
| 144 | ) |
| 145 | } |
| 146 | |
| 147 | if (closePromises.length > 0) { |
| 148 | await Promise.all(closePromises) |
| 149 | logger.info('Socket.IO Redis adapter shutdown complete') |
| 150 | } |
| 151 | } |