mirror of https://gitlab.com/ecentrics/concordia
Apostolos Fanakis
4 years ago
28 changed files with 1619 additions and 352 deletions
@ -1 +1,2 @@ |
|||
UPLOAD_CONTRACTS_DIRECTORY=/mnt/concordia/contracts/ |
|||
LOGS_PATH=/mnt/concordia/logs/ |
|||
|
@ -0,0 +1,9 @@ |
|||
import winston from 'winston'; |
|||
import fs from 'fs'; |
|||
import getLogger from 'concordia-shared/src/logging/node/winstonLogUtils'; |
|||
import constants from '../constants'; |
|||
|
|||
export const logsDirectoryPath = process.env.LOGS_PATH || constants.logsPath; |
|||
fs.mkdirSync(logsDirectoryPath, { recursive: true }); |
|||
|
|||
export const logger = getLogger(winston, logsDirectoryPath, 'concordia-contracts-provider'); |
@ -1,5 +1,4 @@ |
|||
import path from 'path'; |
|||
|
|||
const ORBIT_DIRECTORY_DEFAULT = path.join(__dirname, '..', 'orbitdb'); |
|||
|
|||
export default ORBIT_DIRECTORY_DEFAULT; |
|||
export const ORBIT_DIRECTORY_DEFAULT = path.join(__dirname, '..', 'orbitdb'); |
|||
export const LOGS_PATH = path.join(__dirname, '..', 'logs'); |
|||
|
@ -1,11 +1,12 @@ |
|||
import dns from 'dns'; |
|||
import util from 'util'; |
|||
import { rendezvousHost, rendezvousPort } from 'concordia-shared/src/environment/interpolated/rendezvous'; |
|||
import { logger } from './logger'; |
|||
|
|||
const dnsLookup = util.promisify(dns.lookup); |
|||
|
|||
export const getResolvedRendezvousUrl = async () => dnsLookup(rendezvousHost, { family: 4 }) |
|||
.catch((error) => console.error(new Error(`DNS lookup of ${rendezvousHost} failed.\n${error}`))); |
|||
.catch((error) => logger.error(new Error(`DNS lookup of ${rendezvousHost} failed.\n${error}`))); |
|||
|
|||
export const getSwarmAddresses = async () => getResolvedRendezvousUrl() |
|||
.then((resolvedRendezvousUrl) => [`/ip4/${resolvedRendezvousUrl.address}/tcp/${rendezvousPort}/wss/p2p-webrtc-star`]); |
|||
|
@ -0,0 +1,9 @@ |
|||
import winston from 'winston'; |
|||
import fs from 'fs'; |
|||
import getLogger from 'concordia-shared/src/logging/node/winstonLogUtils'; |
|||
import { LOGS_PATH } from '../constants'; |
|||
|
|||
export const logsDirectoryPath = process.env.LOGS_PATH || LOGS_PATH; |
|||
fs.mkdirSync(logsDirectoryPath, { recursive: true }); |
|||
|
|||
export const logger = getLogger(winston, logsDirectoryPath, 'concordia-pinner'); |
@ -0,0 +1,48 @@ |
|||
const path = require('path'); |
|||
|
|||
const getLogger = (winston, logsDirectory, serviceName) => { |
|||
const transports = [ |
|||
new winston.transports.File({ |
|||
filename: path.join(logsDirectory, 'error.log'), |
|||
level: 'error', |
|||
}), |
|||
new winston.transports.File({ |
|||
filename: path.join(logsDirectory, 'combined.log'), |
|||
}), |
|||
]; |
|||
|
|||
const exceptionHandlers = [ |
|||
new winston.transports.File({ filename: path.join(logsDirectory, 'exceptions.log') }), |
|||
]; |
|||
|
|||
if (process.env.NODE_ENV !== 'production') { |
|||
transports.push(new winston.transports.Console({ |
|||
format: winston.format.combine( |
|||
winston.format.colorize(), |
|||
winston.format.timestamp(), |
|||
winston.format.simple(), |
|||
), |
|||
})); |
|||
|
|||
exceptionHandlers.push(new winston.transports.Console({ |
|||
format: winston.format.combine( |
|||
winston.format.colorize(), |
|||
winston.format.timestamp(), |
|||
winston.format.simple(), |
|||
), |
|||
})); |
|||
} |
|||
|
|||
return winston.createLogger({ |
|||
level: process.env.NODE_ENV === 'production' ? 'info' : 'silly', |
|||
format: winston.format.combine( |
|||
winston.format.timestamp(), |
|||
winston.format.json(), |
|||
), |
|||
defaultMeta: { service: serviceName }, |
|||
transports, |
|||
exceptionHandlers, |
|||
}); |
|||
}; |
|||
|
|||
module.exports = getLogger; |
File diff suppressed because it is too large
Loading…
Reference in new issue