setup.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import subprocess
  2. import setup_util
  3. import os
  4. from os.path import expanduser
  5. home = expanduser("~")
  6. def start(args, logfile, errfile):
  7. setup_util.replace_text("hhvm/once.php.inc", "host=localhost;", "host=" + args.database_host + ";")
  8. setup_util.replace_text("hhvm/deploy/config.hdf", "SourceRoot = .*\/FrameworkBenchmarks", "SourceRoot = " + home + "/FrameworkBenchmarks")
  9. setup_util.replace_text("hhvm/deploy/config.hdf", "Path = .*\/.hhvm.hhbc", "Path = " + home + "/FrameworkBenchmarks/hhvm/.hhvm.bbhc")
  10. setup_util.replace_text("hhvm/deploy/config.hdf", "PidFile = .*\/hhvm.pid", "PidFile = " + home + "/FrameworkBenchmarks/hhvm/hhvm.pid")
  11. setup_util.replace_text("hhvm/deploy/config.hdf", "File = .*\/error.log", "File = " + home + "/FrameworkBenchmarks/hhvm/error.log")
  12. try:
  13. if os.name == 'nt':
  14. # Not supported !
  15. return 0
  16. subprocess.check_call("hhvm --config " + home + "/FrameworkBenchmarks/hhvm/deploy/config.hdf -m daemon", shell=True, stderr=errfile, stdout=logfile)
  17. return 0
  18. except subprocess.CalledProcessError:
  19. return 1
  20. def stop(logfile, errfile):
  21. try:
  22. if os.name == 'nt':
  23. # Not Supported !
  24. return 0
  25. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  26. out, err = p.communicate()
  27. for line in out.splitlines():
  28. if 'hhvm' in line and 'toolset' not in line:
  29. pid = int(line.split(None,2)[1])
  30. os.kill(pid,15)
  31. return 0
  32. except subprocess.CalledProcessError:
  33. return 1