不要怂,就是干,撸起袖子干!

Commit 40cf6bf5 by Dejan Ranisavljevic

Destroy all connections on process exit once pools are drained.

1 parent 40cd8d97
Showing with 9 additions and 4 deletions
...@@ -44,8 +44,12 @@ ConnectionManager = function(dialect, sequelize) { ...@@ -44,8 +44,12 @@ ConnectionManager = function(dialect, sequelize) {
}; };
ConnectionManager.prototype.onProcessExit = function() { ConnectionManager.prototype.onProcessExit = function() {
var self = this
if (this.pool) { if (this.pool) {
this.pool.drain(); this.pool.drain(function() {
self.pool.destroyAllNow();
});
} }
}; };
...@@ -116,9 +120,10 @@ ConnectionManager.prototype.initPools = function () { ...@@ -116,9 +120,10 @@ ConnectionManager.prototype.initPools = function () {
destroy: function(connection) { destroy: function(connection) {
return self.pool[connection.queryType].destroy(connection); return self.pool[connection.queryType].destroy(connection);
}, },
drain: function() { drain: function(cb) {
self.pool.read.drain(); self.pool.write.drain(function() {
self.pool.write.drain(); self.pool.read.drain(cb);
});
}, },
read: Pooling.Pool({ read: Pooling.Pool({
name: 'sequelize-connection-read', name: 'sequelize-connection-read',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!