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