Skip to content

Commit 122fc22

Browse files
Dan Bernardicdougwilson
Dan Bernardic
authored andcommitted
docs: add pool.end() documentation
closes #911 closes #912
1 parent a4dd3dc commit 122fc22

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,24 @@ pool.on('enqueue', function () {
364364
});
365365
```
366366

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+
367385
## PoolCluster
368386

369387
PoolCluster provides multiple hosts connection. (group & retry & selector)

0 commit comments

Comments
 (0)