2023-10-18 04:32:14 -04:00
|
|
|
// Metrics must be initialized before importing anything else
|
|
|
|
import '@overleaf/metrics/initialize.js'
|
|
|
|
|
2022-12-16 05:42:39 -05:00
|
|
|
import logger from '@overleaf/logger'
|
|
|
|
import Settings from '@overleaf/settings'
|
|
|
|
import { mongoClient } from './app/js/mongodb.js'
|
|
|
|
import { app } from './app/js/server.js'
|
|
|
|
|
|
|
|
const { host, port } = Settings.internal.contacts
|
|
|
|
|
|
|
|
try {
|
|
|
|
await mongoClient.connect()
|
|
|
|
} catch (err) {
|
|
|
|
logger.fatal({ err }, 'Cannot connect to mongo. Exiting.')
|
|
|
|
process.exit(1)
|
2020-02-17 02:38:25 -05:00
|
|
|
}
|
|
|
|
|
2022-12-16 05:42:39 -05:00
|
|
|
app.listen(port, host, err => {
|
|
|
|
if (err) {
|
|
|
|
logger.fatal({ err }, `Cannot bind to ${host}:${port}. Exiting.`)
|
|
|
|
process.exit(1)
|
2020-02-17 02:38:26 -05:00
|
|
|
}
|
2022-12-16 05:42:39 -05:00
|
|
|
logger.debug(`contacts starting up, listening on ${host}:${port}`)
|
2020-02-17 02:38:26 -05:00
|
|
|
})
|