settings.defaults.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. const Path = require('path')
  2. module.exports = {
  3. // Options are passed to Sequelize.
  4. // See http://sequelizejs.com/documentation#usage-options for details
  5. mysql: {
  6. clsi: {
  7. database: 'clsi',
  8. username: 'clsi',
  9. dialect: 'sqlite',
  10. storage:
  11. process.env.SQLITE_PATH || Path.resolve(__dirname, '../db/db.sqlite'),
  12. pool: {
  13. max: 1,
  14. min: 1
  15. },
  16. retry: {
  17. max: 10
  18. }
  19. }
  20. },
  21. compileSizeLimit: process.env.COMPILE_SIZE_LIMIT || '7mb',
  22. processLifespanLimitMs:
  23. parseInt(process.env.PROCESS_LIFE_SPAN_LIMIT_MS) || 60 * 60 * 24 * 1000 * 2,
  24. path: {
  25. compilesDir: Path.resolve(__dirname, '../compiles'),
  26. clsiCacheDir: Path.resolve(__dirname, '../cache'),
  27. synctexBaseDir(projectId) {
  28. return Path.join(this.compilesDir, projectId)
  29. }
  30. },
  31. internal: {
  32. clsi: {
  33. port: 3013,
  34. host: process.env.LISTEN_ADDRESS || 'localhost'
  35. },
  36. load_balancer_agent: {
  37. report_load: true,
  38. load_port: 3048,
  39. local_port: 3049
  40. }
  41. },
  42. apis: {
  43. clsi: {
  44. url: `http://${process.env.CLSI_HOST || 'localhost'}:3013`
  45. }
  46. },
  47. smokeTest: process.env.SMOKE_TEST || false,
  48. project_cache_length_ms: 1000 * 60 * 60 * 24,
  49. parallelFileDownloads: process.env.FILESTORE_PARALLEL_FILE_DOWNLOADS || 1,
  50. parallelSqlQueryLimit: process.env.FILESTORE_PARALLEL_SQL_QUERY_LIMIT || 1,
  51. filestoreDomainOveride: process.env.FILESTORE_DOMAIN_OVERRIDE,
  52. texliveImageNameOveride: process.env.TEX_LIVE_IMAGE_NAME_OVERRIDE,
  53. texliveOpenoutAny: process.env.TEXLIVE_OPENOUT_ANY,
  54. sentry: {
  55. dsn: process.env.SENTRY_DSN
  56. }
  57. }
  58. if (process.env.ALLOWED_COMPILE_GROUPS) {
  59. try {
  60. module.exports.allowedCompileGroups = process.env.ALLOWED_COMPILE_GROUPS.split(
  61. ' '
  62. )
  63. } catch (error) {
  64. console.error(error, 'could not apply allowed compile group setting')
  65. process.exit(1)
  66. }
  67. }
  68. if (process.env.DOCKER_RUNNER) {
  69. let seccompProfilePath
  70. module.exports.clsi = {
  71. dockerRunner: process.env.DOCKER_RUNNER === 'true',
  72. docker: {
  73. runtime: process.env.DOCKER_RUNTIME,
  74. image:
  75. process.env.TEXLIVE_IMAGE || 'quay.io/sharelatex/texlive-full:2017.1',
  76. env: {
  77. HOME: '/tmp'
  78. },
  79. socketPath: '/var/run/docker.sock',
  80. user: process.env.TEXLIVE_IMAGE_USER || 'tex'
  81. },
  82. optimiseInDocker: true,
  83. expireProjectAfterIdleMs: 24 * 60 * 60 * 1000,
  84. checkProjectsIntervalMs: 10 * 60 * 1000
  85. }
  86. try {
  87. // Override individual docker settings using path-based keys, e.g.:
  88. // compileGroupDockerConfigs = {
  89. // priority: { 'HostConfig.CpuShares': 100 }
  90. // beta: { 'dotted.path.here', 'value'}
  91. // }
  92. const compileGroupConfig = JSON.parse(
  93. process.env.COMPILE_GROUP_DOCKER_CONFIGS || '{}'
  94. )
  95. module.exports.clsi.docker.compileGroupConfig = compileGroupConfig
  96. } catch (error) {
  97. console.error(error, 'could not apply compile group docker configs')
  98. process.exit(1)
  99. }
  100. try {
  101. seccompProfilePath = Path.resolve(__dirname, '../seccomp/clsi-profile.json')
  102. module.exports.clsi.docker.seccomp_profile = JSON.stringify(
  103. JSON.parse(require('fs').readFileSync(seccompProfilePath))
  104. )
  105. } catch (error) {
  106. console.error(
  107. error,
  108. `could not load seccomp profile from ${seccompProfilePath}`
  109. )
  110. process.exit(1)
  111. }
  112. module.exports.path.synctexBaseDir = () => '/compile'
  113. module.exports.path.sandboxedCompilesHostDir = process.env.COMPILES_HOST_DIR
  114. module.exports.path.synctexBinHostPath = process.env.SYNCTEX_BIN_HOST_PATH
  115. }