overleaf/services/chat/app.js
Eric Mc Sween f9aaa4d5de Merge pull request #10753 from overleaf/em-upgrade-mongo-driver
Upgrade the Mongo driver in the chat service

GitOrigin-RevId: 12808e624b75f0adc7fd474f774b855dc2eadefd
2022-12-09 09:04:17 +00:00

28 lines
784 B
JavaScript

const logger = require('@overleaf/logger')
const settings = require('@overleaf/settings')
const { mongoClient } = 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
mongoClient
.connect()
.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}`)
})
})
.catch(err => {
logger.fatal({ err }, 'Cannot connect to mongo. Exiting.')
process.exit(1)
})
}
module.exports = Server.server