mirror of
https://github.com/docker-training/node-bulletin-board.git
synced 2025-07-02 13:49:32 +08:00
Add logging & db config
This commit is contained in:
parent
68b8cd014c
commit
b9818a6450
48
bb-stack-final.yaml
Normal file
48
bb-stack-final.yaml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
version: '3.7'
|
||||||
|
|
||||||
|
services:
|
||||||
|
bb-db:
|
||||||
|
image: ${dockerId}/bb-db:v3
|
||||||
|
build:
|
||||||
|
context: ./bulletin-board-db
|
||||||
|
networks:
|
||||||
|
- bb-net
|
||||||
|
volumes:
|
||||||
|
- sqlbackup:/var/opt/mssql
|
||||||
|
|
||||||
|
bb-app:
|
||||||
|
image: ${dockerId}/bb-app:v3.3
|
||||||
|
build:
|
||||||
|
context: ./bulletin-board-app
|
||||||
|
dockerfile: Dockerfile.v3.3
|
||||||
|
networks:
|
||||||
|
- bb-net
|
||||||
|
configs:
|
||||||
|
- source: logConfig
|
||||||
|
target: /app/config/logConfig.js
|
||||||
|
secrets:
|
||||||
|
- source: dbConfig
|
||||||
|
target: /app/config/dbConfig.js
|
||||||
|
|
||||||
|
bb-proxy:
|
||||||
|
image: ${dockerId}/bb-proxy:v3
|
||||||
|
build:
|
||||||
|
context: ./bulletin-board-proxy
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
networks:
|
||||||
|
- bb-net
|
||||||
|
|
||||||
|
networks:
|
||||||
|
bb-net:
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
sqlbackup:
|
||||||
|
|
||||||
|
configs:
|
||||||
|
logConfig:
|
||||||
|
external: true
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
dbConfig:
|
||||||
|
external: true
|
@ -2,10 +2,15 @@ var Sequelize = require('sequelize');
|
|||||||
var dbConfig = require('../config/dbConfig');
|
var dbConfig = require('../config/dbConfig');
|
||||||
var log = require('../log');
|
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',
|
dialect: 'mssql',
|
||||||
host: dbConfig.options.host,
|
host: dbConfig.connection.host,
|
||||||
port: dbConfig.options.port,
|
port: dbConfig.connection.port,
|
||||||
|
pool: {
|
||||||
|
max: dbConfig.pool.max
|
||||||
|
},
|
||||||
dialectOptions: {
|
dialectOptions: {
|
||||||
requestTimeout: 30000
|
requestTimeout: 30000
|
||||||
}
|
}
|
||||||
@ -14,7 +19,8 @@ var sequelize = new Sequelize(dbConfig.options.dbName, dbConfig.options.username
|
|||||||
sequelize
|
sequelize
|
||||||
.authenticate()
|
.authenticate()
|
||||||
.then(() => {
|
.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 => {
|
.catch(err => {
|
||||||
log.Logger.error('** SQL Server connection failed: ', err);
|
log.Logger.error('** SQL Server connection failed: ', err);
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
var dbConfig = module.exports = {};
|
var dbConfig = module.exports = {};
|
||||||
|
|
||||||
dbConfig.options = {
|
dbConfig.connection = {
|
||||||
username: 'sa',
|
username: 'sa',
|
||||||
password: 'DockerCon!!!',
|
password: 'DockerCon!!!',
|
||||||
host: 'bb-db',
|
host: 'bb-db',
|
||||||
post: 1433,
|
post: 1433,
|
||||||
dbName: 'BulletinBoard'
|
dbName: 'BulletinBoard'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dbConfig.pool = {
|
||||||
|
max: 10
|
||||||
|
};
|
@ -1,10 +1,14 @@
|
|||||||
const winston = require('winston');
|
const { format, transports } = require('winston');
|
||||||
var logConfig = module.exports = {};
|
var logConfig = module.exports = {};
|
||||||
|
|
||||||
logConfig.options = {
|
logConfig.options = {
|
||||||
|
format: format.combine(
|
||||||
|
format.splat(),
|
||||||
|
format.simple()
|
||||||
|
),
|
||||||
transports: [
|
transports: [
|
||||||
new winston.transports.Console({
|
new transports.Console({
|
||||||
level: 'info'
|
level: 'debug'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user