setup.py 832 B

1234567891011121314151617181920212223242526272829303132
  1. import subprocess
  2. import setup_util
  3. import multiprocessing
  4. import os
  5. bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/py2/bin')
  6. NCPU = multiprocessing.cpu_count()
  7. proc = None
  8. def start(args):
  9. global proc
  10. setup_util.replace_text("flask/app.py", "DBHOSTNAME", args.database_host)
  11. proc = subprocess.Popen([
  12. bin_dir + "/gunicorn",
  13. "app:app",
  14. "-k", "meinheld.gmeinheld.MeinheldWorker",
  15. "-b", "0.0.0.0:8080",
  16. '-w', str(NCPU*3),
  17. "--log-level=critical"],
  18. cwd="flask")
  19. return 0
  20. def stop():
  21. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  22. out, err = p.communicate()
  23. for line in out.splitlines():
  24. if 'FrameworkBenchmarks/installs/py2/bin/' in line:
  25. pid = int(line.split(None,2)[1])
  26. kill(pid, 9)
  27. return 0