Enabling test server and bug fixes

This commit is contained in:
John Lyon-Smith
2018-04-20 17:40:55 -07:00
parent acfbc52cf9
commit f7c73ee277
15 changed files with 399 additions and 126 deletions

View File

@@ -1,18 +1,19 @@
#!/usr/bin/env node
import { ServerTool } from './ServerTool'
import pino from 'pino'
import * as pinoExpress from 'pino-pretty-express'
import path from 'path'
import fs from 'fs'
import config from 'config'
import { ServerTool } from "./ServerTool"
import pino from "pino"
import * as pinoExpress from "pino-pretty-express"
import path from "path"
import fs from "fs"
import config from "config"
const serviceName = 'dar-server'
const isProduction = (process.env.NODE_ENV == 'production')
const serviceName = config.get("serviceName.server")
const isProduction = process.env.NODE_ENV === "production"
let log = null
if (isProduction) {
log = pino( { name: serviceName },
fs.createWriteStream(path.join(config.get('logDir'), serviceName + '.log'))
log = pino(
{ name: serviceName },
fs.createWriteStream(path.join(config.get("logDir"), serviceName + ".log"))
)
} else {
const pretty = pinoExpress.pretty({})
@@ -20,10 +21,13 @@ if (isProduction) {
log = pino({ name: serviceName }, pretty)
}
const tool = new ServerTool(path.basename(process.argv[1], '.js'), log)
const tool = new ServerTool(path.basename(process.argv[1], ".js"), log)
tool.run(process.argv.slice(2)).then((exitCode) => {
process.exitCode = exitCode
}).catch((err) => {
console.error(err)
})
tool
.run(process.argv.slice(2))
.then((exitCode) => {
process.exitCode = exitCode
})
.catch((err) => {
console.error(err)
})