This implements the configuration mechanism I described in #2621. The heavy lifting is delegated to [node-config](https://github.com/lorenwest/node-config) with a minor assist from [dotenv](https://github.com/motdotla/dotenv). `private/secret.json` has been replaced with environment variables and/or `config/local.yml`. See `doc/server-secrets.md`.
34 lines
775 B
JavaScript
34 lines
775 B
JavaScript
'use strict'
|
|
|
|
require('dotenv').config()
|
|
|
|
// Set up Sentry reporting as early in the process as possible.
|
|
const Raven = require('raven')
|
|
const serverSecrets = require('./lib/server-secrets')
|
|
|
|
Raven.config(process.env.SENTRY_DSN || serverSecrets.sentry_dsn).install()
|
|
Raven.disableConsoleAlerts()
|
|
|
|
const config = require('config').util.toObject()
|
|
if (+process.argv[2]) {
|
|
config.public.bind.port = +process.argv[2]
|
|
}
|
|
if (+process.argv[3]) {
|
|
config.public.bind.address = +process.argv[3]
|
|
}
|
|
|
|
console.log('Configuration:')
|
|
console.dir(config.public, { depth: null })
|
|
|
|
const Server = require('./lib/server')
|
|
const server = (module.exports = new Server(config))
|
|
|
|
;(async () => {
|
|
try {
|
|
await server.start()
|
|
} catch (e) {
|
|
console.error(e)
|
|
process.exit(1)
|
|
}
|
|
})()
|