ClsiApp.js 551 B

12345678910111213141516171819202122232425262728293031
  1. import app from '../../../../app.js'
  2. import Settings from '@overleaf/settings'
  3. function startApp() {
  4. return new Promise((resolve, reject) => {
  5. app.listen(
  6. Settings.internal.clsi.port,
  7. Settings.internal.clsi.host,
  8. error => {
  9. if (error) {
  10. reject(error)
  11. } else {
  12. resolve()
  13. }
  14. }
  15. )
  16. })
  17. }
  18. let appStartedPromise
  19. async function ensureRunning() {
  20. if (!appStartedPromise) {
  21. appStartedPromise = startApp()
  22. }
  23. await appStartedPromise
  24. }
  25. export default {
  26. ensureRunning,
  27. }