overleaf/services/chat/app.js

29 lines
774 B
JavaScript
Raw Normal View History

const logger = require('@overleaf/logger')
const settings = require('@overleaf/settings')
2014-08-15 05:50:36 -04:00
const mongodb = require('./app/js/mongodb')
const Server = require('./app/js/server')
2014-08-15 06:35:22 -04:00
if (!module.parent) {
// Called directly
const port = settings.internal.chat.port
const host = settings.internal.chat.host
mongodb
.waitForDb()
.then(() => {
Server.server.listen(port, host, function (err) {
if (err) {
logger.fatal({ err }, `Cannot bind to ${host}:${port}. Exiting.`)
process.exit(1)
}
logger.debug(`Chat starting up, listening on ${host}:${port}`)
})
})
2021-07-13 07:04:48 -04:00
.catch(err => {
logger.fatal({ err }, 'Cannot connect to mongo. Exiting.')
process.exit(1)
})
}
2014-08-15 06:35:22 -04:00
module.exports = Server.server