setup.py 927 B

123456789101112131415161718192021222324252627282930313233343536
  1. import subprocess
  2. import setup_util
  3. import multiprocessing
  4. import os
  5. home = os.path.expanduser('~')
  6. bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/py2/bin')
  7. NCPU = multiprocessing.cpu_count()
  8. proc = None
  9. def start(args):
  10. global proc
  11. setup_util.replace_text("django/hello/hello/settings.py", "HOST': '.*'", "HOST': '" + args.database_host + "'")
  12. setup_util.replace_text("django/hello/hello/settings.py", "\/home\/ubuntu", home)
  13. env = os.environ.copy()
  14. env['DJANGO_DB'] = 'mysql'
  15. proc = subprocess.Popen([
  16. bin_dir + "/gunicorn",
  17. "hello.wsgi:application",
  18. "-k", "meinheld.gmeinheld.MeinheldWorker",
  19. "-b", "0.0.0.0:8080",
  20. '-w', str(NCPU*3),
  21. "--log-level=critical"],
  22. cwd="django/hello")
  23. return 0
  24. def stop():
  25. global proc
  26. if proc is None:
  27. return 0
  28. proc.terminate()
  29. proc.wait()
  30. proc = None
  31. return 0