-
Notifications
You must be signed in to change notification settings - Fork 4
/
bootstrap.js
24 lines (20 loc) · 874 Bytes
/
bootstrap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const MYSQL = require('mysql');
var db_config = {
host: process.env.MYSQL_HOST || Config.databaseSettings.MYSQL_HOST,
user: process.env.MYSQL_USER || Config.databaseSettings.MYSQL_USER,
password: process.env.MYSQL_PASS || Config.databaseSettings.MYSQL_PASS,
database: process.env.MYSQL_DBNAME || Config.databaseSettings.MYSQL_DBNAME,
port: process.env.MYSQL_PORT || Config.databaseSettings.MYSQL_PORT,
multipleStatements: true
};
function initializeConnectionPool(db_config){
var numConnectionsInPool = 0;
console.log('CALLING INITIALIZE POOL');
var conn = MYSQL.createPool(db_config);
conn.on('connection', function (connection) {
numConnectionsInPool++;
console.log('NUMBER OF CONNECTION IN POOL : ', numConnectionsInPool);
});
return conn;
}
global.connection = initializeConnectionPool(db_config);