setup_benchmark.py 708 B

12345678910111213141516171819202122232425262728293031323334
  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/py3/bin')
  7. NCPU = multiprocessing.cpu_count()
  8. proc = None
  9. def start(args):
  10. global proc
  11. setup_util.replace_text(
  12. "frameworkbenchmarks/models.py",
  13. "DBHOSTNAME = 'localhost'",
  14. "DBHOSTNAME = '%s'" % args.database_host
  15. )
  16. proc = subprocess.Popen([
  17. bin_dir + '/gunicorn',
  18. 'wsgi:app',
  19. '-b', "0.0.0.0:6543",
  20. '-w', str(NCPU*3)],
  21. cwd='pyramid'
  22. )
  23. return 0
  24. def stop():
  25. global proc
  26. if proc is not None:
  27. proc.terminate()
  28. proc.wait()
  29. return 0