app.js 746 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 { app } from './app/js/server.js'
  6. import * as ASpell from './app/js/ASpell.js'
  7. import Metrics from '@overleaf/metrics'
  8. const { host = 'localhost', port = 3005 } = Settings.internal?.spelling ?? {}
  9. ASpell.startCacheDump()
  10. const server = app.listen(port, host, function (error) {
  11. if (error) {
  12. throw error
  13. }
  14. logger.info({ host, port }, 'spelling HTTP server starting up')
  15. })
  16. process.on('SIGTERM', () => {
  17. ASpell.stopCacheDump()
  18. server.close(() => {
  19. logger.info({ host, port }, 'spelling HTTP server closed')
  20. Metrics.close()
  21. })
  22. })