mirror of
https://github.com/docker-training/node-bulletin-board.git
synced 2025-12-13 06:16:43 +08:00
Add logging & db config
This commit is contained in:
@@ -2,19 +2,25 @@ var Sequelize = require('sequelize');
|
||||
var dbConfig = require('../config/dbConfig');
|
||||
var log = require('../log');
|
||||
|
||||
var sequelize = new Sequelize(dbConfig.options.dbName, dbConfig.options.username, dbConfig.options.password, {
|
||||
log.Logger.debug('Initializing connection to SQL Server: %s', dbConfig.connection.host);
|
||||
|
||||
var sequelize = new Sequelize(dbConfig.connection.dbName, dbConfig.connection.username, dbConfig.connection.password, {
|
||||
dialect: 'mssql',
|
||||
host: dbConfig.options.host,
|
||||
port: dbConfig.options.port,
|
||||
host: dbConfig.connection.host,
|
||||
port: dbConfig.connection.port,
|
||||
pool: {
|
||||
max: dbConfig.pool.max
|
||||
},
|
||||
dialectOptions: {
|
||||
requestTimeout: 30000
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
sequelize
|
||||
.authenticate()
|
||||
.then(() => {
|
||||
log.Logger.info('Successful connection to SQL Server.');
|
||||
log.Logger.info('Successful connection to SQL Server: %s', dbConfig.connection.host);
|
||||
log.Logger.info('--Using connection pool max: %d', dbConfig.pool.max)
|
||||
})
|
||||
.catch(err => {
|
||||
log.Logger.error('** SQL Server connection failed: ', err);
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
var dbConfig = module.exports = {};
|
||||
|
||||
dbConfig.options = {
|
||||
dbConfig.connection = {
|
||||
username: 'sa',
|
||||
password: 'DockerCon!!!',
|
||||
host: 'bb-db',
|
||||
post: 1433,
|
||||
dbName: 'BulletinBoard'
|
||||
};
|
||||
|
||||
dbConfig.pool = {
|
||||
max: 10
|
||||
};
|
||||
@@ -1,10 +1,14 @@
|
||||
const winston = require('winston');
|
||||
const { format, transports } = require('winston');
|
||||
var logConfig = module.exports = {};
|
||||
|
||||
logConfig.options = {
|
||||
format: format.combine(
|
||||
format.splat(),
|
||||
format.simple()
|
||||
),
|
||||
transports: [
|
||||
new winston.transports.Console({
|
||||
level: 'info'
|
||||
new transports.Console({
|
||||
level: 'debug'
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user