setup.py 1.4 KB

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