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