Skip to content

Commit

Permalink
use pooling
Browse files Browse the repository at this point in the history
  • Loading branch information
cvweiss committed Sep 17, 2019
1 parent 27101c9 commit 1b91a96
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
11 changes: 0 additions & 11 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,3 @@ app.mysql = mysql;

//var update_chars = require('./bin/update_chars.js');
//update_chars(mysql);

//setTimeout(function() { process.exit(0); }, 60000);
setInterval(function() { checkMysql(app); }, 15000);
async function checkMysql(app) {
try {
let result = await app.mysql.query('select * from ew_characters limit 5');
} catch (e) {
console.log('Lost mysql connection');
process.exit(1);
}
}
3 changes: 2 additions & 1 deletion classes/Database.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const mysql = require( 'mysql' );
class Database {
constructor( config ) {
this.connection = mysql.createConnection( config );
//this.connection = mysql.createConnection( config );
this.connection = mysql.createPool( config );
}
query( sql, args ) {
return new Promise( ( resolve, reject ) => {
Expand Down

0 comments on commit 1b91a96

Please sign in to comment.