setup_py2.py 951 B

123456789101112131415161718192021222324252627282930313233343536
  1. import subprocess
  2. import setup_util
  3. import multiprocessing
  4. import os
  5. home = os.path.expanduser('~')
  6. pyramid_dir = home + "/FrameworkBenchmarks/pyramid"
  7. bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/py2/bin')
  8. NCPU = multiprocessing.cpu_count()
  9. proc = None
  10. def start(args, logfile, errfile):
  11. global proc
  12. setup_util.replace_text(
  13. pyramid_dir + "/frameworkbenchmarks/models.py",
  14. "DBHOSTNAME = 'localhost'",
  15. "DBHOSTNAME = '%s'" % args.database_host
  16. )
  17. subprocess.call(bin_dir + '/pip install -e .', cwd='pyramid', shell=True, stderr=errfile, stdout=logfile)
  18. proc = subprocess.Popen([
  19. bin_dir + '/gunicorn',
  20. 'wsgi:app',
  21. '-b', "0.0.0.0:6543",
  22. '-w', str(NCPU*3)],
  23. cwd='pyramid', stderr=errfile, stdout=logfile
  24. )
  25. return 0
  26. def stop(logfile, errfile):
  27. global proc
  28. if proc is not None:
  29. proc.terminate()
  30. proc.wait()
  31. return 0