app.js 836 B

12345678910111213141516171819202122232425262728
  1. // Metrics must be initialized before importing anything else
  2. import '@overleaf/metrics/initialize.js'
  3. import Settings from '@overleaf/settings'
  4. import logger from '@overleaf/logger'
  5. import OError from '@overleaf/o-error'
  6. import { mongoClient } from './app/js/mongodb.js'
  7. import { app } from './app/js/server.js'
  8. const host = Settings.internal.history.host
  9. const port = Settings.internal.history.port
  10. mongoClient
  11. .connect()
  12. .then(() => {
  13. app.listen(port, host, error => {
  14. if (error) {
  15. error = OError.tag(error, 'could not start history server')
  16. logger.error({ error }, error.message)
  17. } else {
  18. logger.debug({}, `history starting up, listening on ${host}:${port}`)
  19. }
  20. })
  21. })
  22. .catch(err => {
  23. logger.fatal({ err }, 'Cannot connect to mongo. Exiting.')
  24. process.exit(1)
  25. })