setup.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import setup_util
  2. import subprocess
  3. import sys
  4. import time
  5. import os
  6. def start(args, logfile, errfile):
  7. setup_util.replace_text("plain/src/main/resources/application.conf", "127.0.0.1", args.database_host)
  8. if os.name == 'nt':
  9. subprocess.check_call(".\sbt.bat assembly && del /f /s /q target\scala-2.10\cache", shell=True, cwd="plain", stderr=errfile, stdout=logfile)
  10. else:
  11. subprocess.check_call("./sbt assembly && rm -rf target/scala-2.10/cache", shell=True, cwd="plain", stderr=errfile, stdout=logfile)
  12. subprocess.Popen("java -server -da -dsa -Xrs -Xmx6g -Xmn4g -Xss8m -Xnoclassgc -XX:MaxPermSize=1g -XX:ReservedCodeCacheSize=384m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -jar target/scala-2.10/plain-benchmark-assembly-1.0.1.jar", cwd="plain", shell=True, stderr=errfile, stdout=logfile)
  13. time.sleep(10)
  14. return 0
  15. def stop(logfile, errfile):
  16. if os.name == 'nt':
  17. subprocess.call("taskkill /f /im *plain-benchmark* > NUL", shell=True, stderr=errfile, stdout=logfile)
  18. return 0
  19. # Takes up so much disk space
  20. if os.name == 'nt':
  21. subprocess.check_call("del /f /s /q target && del /f /s /q project", shell=True, cwd="plain", stderr=errfile, stdout=logfile)
  22. else:
  23. subprocess.check_call("rm -rf target && rm -rf project", shell=True, cwd="plain", stderr=errfile, stdout=logfile)
  24. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  25. out, err = p.communicate()
  26. for line in out.splitlines():
  27. if 'plain-benchmark' in line:
  28. try:
  29. pid = int(line.split(None, 2)[1])
  30. os.kill(pid, 15)
  31. except OSError:
  32. pass
  33. return 0