/contrib/vm/vmfiles/sagecell/config.py

https://github.com/shannonzylstra/sagecell · Python · 71 lines · 40 code · 12 blank · 19 comment · 4 complexity · 3181b2da994403b4d69ad1fce946d8fe MD5 · raw file

  1. import os.path
  2. # location of a sage executable
  3. sage = ""
  4. # defaults if sage isn't set above
  5. if sage == "":
  6. if 'SAGE_ROOT' in os.environ:
  7. # assume that the untrusted worker should run the same copy of sage
  8. # that is used to run the web server
  9. sage = os.path.join(os.environ["SAGE_ROOT"],"sage")
  10. else:
  11. # assume both the web server and the untrusted workers have sage in their paths
  12. sage = "sage"
  13. #db = "sqlalchemy"
  14. #db_config = {"uri": "sqlite:///sqlite.db"}
  15. db = "web"
  16. db_config = {"uri": "https://sagecell.sagemath.org/permalink"}
  17. # db = "web"
  18. # db_config = {"uri": "http://localhost:8889"}
  19. requires_tos = True
  20. permalink_server = {
  21. 'db': 'sqlalchemy',
  22. 'db_config': {'uri': 'sqlite:///sqlite.db'}
  23. }
  24. max_kernel_timeout = 60*90 # 90 minutes, for interacts
  25. pid_file='/home/sageserver/sagecell.pid'
  26. computers = []
  27. _default_config = {"host": "localhost",
  28. "username": 'sageworker',
  29. "python": sage + " -python",
  30. "location": os.path.dirname(os.path.abspath(__file__)),
  31. # The keys to resource_limits can be any available resources
  32. # for the resource module. See http://docs.python.org/library/resource.html
  33. # for more information (section 35.13.1)
  34. # Note: RLIMIT_NPROC doesn't really work
  35. # Note: RLIMIT_AS is more of a suggestion than a hard limit in Mac OS X
  36. # Note: All other resource limits seem to be working, but besides RLIMIT_CPU and
  37. # RLIMIT_AS they don't actually kill off offending processes
  38. "resource_limits": {"RLIMIT_CPU": 120, # CPU time in seconds
  39. "RLIMIT_AS": 3*(2**30), #Maximum address space in bytes; this sets 3 GB
  40. },
  41. # The log file will be in the home directory of the untrusted account
  42. "log_file": "sagecell.log",
  43. "max_kernels": 30,
  44. "preforked_kernels": 5,
  45. # These set paramaters for a heartbeat channel checking whether a given kernel is alive.
  46. # Setting first_beat lower than 1.0 may cause javascript errors.
  47. "beat_interval": 0.5,
  48. "first_beat": 1.0}
  49. for i in xrange(4):
  50. computers.append(_default_config)
  51. import logging
  52. from logging.handlers import SysLogHandler
  53. h = SysLogHandler(address='/dev/log', facility=SysLogHandler.LOG_LOCAL3)
  54. h.setFormatter(logging.Formatter('%(asctime)s %(name)s %(process)d: %(message)s'))
  55. logging.getLogger('sagecell.stats').addHandler(h)
  56. systemlog_handler = SysLogHandler(address='/dev/log', facility=SysLogHandler.LOG_LOCAL4)
  57. systemlog_handler.setFormatter(logging.Formatter('%(asctime)s %(name)s %(process)d: %(message)r'))
  58. logging.getLogger("tornado.application").addHandler(systemlog_handler)
  59. logging.getLogger('sagecell.system').addHandler(systemlog_handler)