Skip to content

Commit

Permalink
Allow mysql port in .ini file
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed May 9, 2024
1 parent 6ae3275 commit 801d123
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/makedb.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ import fs from 'fs';
*/
export function makeDb(logger, iniConfig) {
const host = iniConfig['hebcal.mysql.host'];
const port = +(iniConfig['hebcal.mysql.port']) || 3306;
const user = iniConfig['hebcal.mysql.user'];
const password = iniConfig['hebcal.mysql.password'];
const database = iniConfig['hebcal.mysql.dbname'];
logger.info(`Connecting to mysql://${user}@${host}/${database}`);
const connURL = `mysql://${user}@${host}:${port}/${database}`;
logger.info(`Connecting to ${connURL}`);
const connection = mysql.createConnection({
host,
port,
user,
password,
database,
});
connection.connect(function(err) {
if (err) {
logger.fatal(err);
logger.fatal(err, `Cannot connect to ${connURL}`);
throw err;
}
logger.debug('connected as id ' + connection.threadId);
Expand Down

0 comments on commit 801d123

Please sign in to comment.