Skip to content

Commit c83c1d0

Browse files
committed
Switch to connection pool
1 parent 1c36ca7 commit c83c1d0

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

models/db.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ if (process.env.spec === "true") {
88
db = settings.db.spec
99
}
1010

11-
var connection = mysql.createConnection({
11+
var connection = mysql.createPool({
12+
connectionLimit: 10,
1213
host: db.host,
1314
socketPath: db.socketPath,
1415
database: db.database,
@@ -19,11 +20,7 @@ var connection = mysql.createConnection({
1920

2021
module.exports.init = function(cb) {
2122

22-
connection.connect(err => {
23-
if (err) {
24-
return logger('[db]: error connecting: ' + err.stack);
25-
}
26-
23+
connection.on('connection', connection => {
2724
logger('[db]: connected as id ' + connection.threadId);
2825
cb();
2926
});

0 commit comments

Comments
 (0)