Skip to content

Commit 34d0a80

Browse files
committed
Fix close connections readme section
1 parent c782033 commit 34d0a80

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,23 @@ Name | Listener Arguments | Description
6969

7070
## Closing connections between hot code-pushes
7171

72-
With Meteor's hot code-push feature, a new connection the database server is requested with each restart. In order to close old connections, a handler to your application process's `SIGTERM` signal event must be added that calls the `end()` method on each `LiveMysql` instance in your application.
72+
With Meteor's hot code-push feature, a new connection the database server is requested with each restart. In order to close old connections, a handler to your application process's `SIGTERM` signal event must be added that calls the `end()` method on each `LiveMysql` instance in your application. Also, a handler for `SIGINT` can be used to close connections on exit.
7373

74-
On the server-side of your application, add the event handler like this:
74+
On the server-side of your application, add event handlers like this:
7575

7676
```javascript
77+
7778
var liveDb = new LiveMysql(Meteor.settings.mysql);
7879

79-
process.on('SIGTERM', function() {
80+
var closeAndExit = function() {
8081
liveDb.end();
8182
process.exit();
82-
});
83+
};
84+
85+
// Close connections on hot code push
86+
process.on('SIGTERM', closeAndExit);
87+
// Close connections on exit (ctrl + c)
88+
process.on('SIGINT', closeAndExit);
8389
```
8490

8591
## Tests / Benchmarks

0 commit comments

Comments
 (0)