config.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author David Sehnal <david.sehnal@gmail.com>
  5. */
  6. const config = {
  7. /**
  8. * Determine if and how long to cache entries after a request.
  9. */
  10. cacheParams: {
  11. useCache: true,
  12. maxApproximateSizeInBytes: 2 * 1014 * 1024 * 1024, // 2 GB
  13. entryTimeoutInMs: 10 * 60 * 1000 // 10 minutes
  14. },
  15. /**
  16. * Node (V8) sometimes exhibits GC related issues that significantly slow down the execution
  17. * (https://github.com/nodejs/node/issues/8670).
  18. *
  19. * Therefore an option is provided that automatically shuts down the server.
  20. * For this to work, the server must be run using a deamon (i.e. forever.js on Linux
  21. * or IISnode on Windows) so that the server is automatically restarted when the shutdown happens.
  22. */
  23. shutdownParams: {
  24. // 0 for off, server will shut down after this amount of minutes.
  25. timeoutMinutes: 24 * 60 /* a day */,
  26. // modifies the shutdown timer by +/- timeoutVarianceMinutes (to avoid multiple instances shutting at the same time)
  27. timeoutVarianceMinutes: 60
  28. },
  29. defaultPort: 1337,
  30. /**
  31. * Specify the prefix of the API, i.e.
  32. * <host>/<apiPrefix>/<API queries>
  33. */
  34. appPrefix: '/ModelServer',
  35. /**
  36. * The maximum time the server dedicates to executing a query.
  37. * Does not include the time it takes to read and export the data.
  38. */
  39. maxQueryTimeInMs: 5 * 1000,
  40. /** Maximum number of requests before "server busy" */
  41. maxQueueLength: 30,
  42. /**
  43. * Maps a request identifier to a filename.
  44. *
  45. * @param source
  46. * Source of the data.
  47. * @param id
  48. * Id provided in the request.
  49. */
  50. mapFile(source: string, id: string) {
  51. switch (source.toLowerCase()) {
  52. // case 'pdb': return `e:/test/quick/${id}_updated.cif`;
  53. case 'pdb': return `e:/test/mol-star/model/out/${id}_updated.bcif`;
  54. default: return void 0;
  55. }
  56. }
  57. };
  58. export default config;