app.js 799 B

123456789101112131415161718192021222324252627
  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 != null) {
  15. logger.error(OError.tag(error, 'could not start history server'))
  16. } else {
  17. logger.debug(`history starting up, listening on ${host}:${port}`)
  18. }
  19. })
  20. })
  21. .catch(err => {
  22. logger.fatal({ err }, 'Cannot connect to mongo. Exiting.')
  23. process.exit(1)
  24. })