overleaf/services/chat/app.js
Tim Alby ea8e0af551 decaf cleanup: rewrite code to no longer use __guard__
GitOrigin-RevId: 591dbefe98423ead89505250c4f46c8ad2610305
2022-01-14 09:02:52 +00:00

28 lines
773 B
JavaScript

const logger = require('@overleaf/logger')
const settings = require('@overleaf/settings')
const mongodb = require('./app/js/mongodb')
const Server = require('./app/js/server')
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.info(`Chat starting up, listening on ${host}:${port}`)
})
})
.catch(err => {
logger.fatal({ err }, 'Cannot connect to mongo. Exiting.')
process.exit(1)
})
}
module.exports = Server.server