Skip to content

Commit

Permalink
Hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
characat0 committed Dec 10, 2019
1 parent c96f22a commit 74f33b2
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions model/Classes/MySQLDataBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ const Curso = require('./Curso');

class MySQLDataBase {
constructor(host, user, password, database, port, cacheTime) {
this.conn = mysql.createConnection({
host : host,
user : user,
password : password,
database : database,
port : port
});
this.config = {
host : host,
user : user,
password : password,
database : database,
port : port
};
this.conn = mysql.createConnection(this.config);
this.Archivo = 'Archivo';
this.Ciclo = 'Ciclo';
this.Curso = 'Curso';
Expand All @@ -25,16 +26,18 @@ class MySQLDataBase {

this.cache = new CacheHandler(cacheTime);
this.conn.on('error' , (error) => {
console.log("ERROR FOUND!");
console.error(error);
if (error.code === 'PROTOCOL_CONNECTION_LOST') {
setTimeout(() =>
this.connect(process.env.MYSQL_RECONNECTION_TIME)
.then((interval) => {
console.log('Successful Reconnection to database.');
clearInterval(interval);
}), 1000);
}
console.log("ERROR FOUND!");
console.error(error);
if (error.code === 'PROTOCOL_CONNECTION_LOST') {
setTimeout(() => {
this.conn = mysql.createConnection(this.config);
this.connect(process.env.MYSQL_RECONNECTION_TIME)
.then((interval) => {
console.log('Successful Reconnection to database.');
clearInterval(interval);
})
}, 1000);
}
});
}
}
Expand Down

0 comments on commit 74f33b2

Please sign in to comment.