2023-10-18 04:32:14 -04:00
|
|
|
// Metrics must be initialized before importing anything else
|
|
|
|
import '@overleaf/metrics/initialize.js'
|
|
|
|
|
2022-12-13 07:37:49 -05:00
|
|
|
import logger from '@overleaf/logger'
|
|
|
|
import settings from '@overleaf/settings'
|
|
|
|
import { mongoClient } from './app/js/mongodb.js'
|
2023-01-04 10:07:58 -05:00
|
|
|
import { createServer } from './app/js/server.js'
|
2014-08-15 05:50:36 -04:00
|
|
|
|
2022-12-13 07:37:49 -05:00
|
|
|
const port = settings.internal.chat.port
|
|
|
|
const host = settings.internal.chat.host
|
|
|
|
mongoClient
|
|
|
|
.connect()
|
2023-01-04 10:07:58 -05:00
|
|
|
.then(async () => {
|
|
|
|
const { server } = await createServer()
|
2022-12-13 07:37:49 -05:00
|
|
|
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}`)
|
2020-08-19 08:06:22 -04:00
|
|
|
})
|
2022-12-13 07:37:49 -05:00
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
logger.fatal({ err }, 'Cannot connect to mongo. Exiting.')
|
|
|
|
process.exit(1)
|
|
|
|
})
|