overleaf/services/chat/app.js

29 lines
784 B
JavaScript
Raw Normal View History

const logger = require('@overleaf/logger')
const settings = require('@overleaf/settings')
2014-08-15 09:50:36 +00:00
const { mongoClient } = require('./app/js/mongodb')
const Server = require('./app/js/server')
2014-08-15 10:35:22 +00:00
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}`)
})
})
2021-07-13 11:04:48 +00:00
.catch(err => {
logger.fatal({ err }, 'Cannot connect to mongo. Exiting.')
process.exit(1)
})
}
2014-08-15 10:35:22 +00:00
module.exports = Server.server