File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -364,6 +364,27 @@ pool.on('enqueue', function () {
364
364
});
365
365
```
366
366
367
+ ## Closing all the connections in a pool
368
+
369
+ When you are done using the pool, you have to end all the connections or the
370
+ Node.js event loop will stay active until the connections are closed by the
371
+ MySQL server. This is typically done if the pool is used in a script or when
372
+ trying to gracefully shutdown a server. To end all the connections in the
373
+ pool, use the ` end ` method on the pool:
374
+
375
+ ``` js
376
+ pool .end (function (err ) {
377
+ // all connections in the pool have ended
378
+ });
379
+ ```
380
+
381
+ The ` end ` method takes an _ optional_ callback that you can use to know once
382
+ all the connections have ended. The connections end _ gracefully_ , so all
383
+ pending queries will still complete and the time to end the pool will vary.
384
+
385
+ ** Once ` pool.end() ` has been called, ` pool.getConnection ` and other operations
386
+ can no longer be performed**
387
+
367
388
## PoolCluster
368
389
369
390
PoolCluster provides multiple hosts connection. (group & retry & selector)
You can’t perform that action at this time.
0 commit comments