setup.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import setup_util
  2. import subprocess
  3. import sys
  4. import time
  5. import os
  6. def start(args):
  7. setup_util.replace_text("plain/src/main/resources/application.conf", "X127.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")
  10. else:
  11. subprocess.check_call("./sbt assembly && rm -rf target/scala-2.10/cache", shell=True, cwd="plain")
  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)
  13. time.sleep(10)
  14. return 0
  15. def stop():
  16. if os.name == 'nt':
  17. subprocess.call("taskkill /f /im *plain-benchmark* > NUL", shell=True)
  18. return 0
  19. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  20. out, err = p.communicate()
  21. for line in out.splitlines():
  22. if 'plain-benchmark' in line:
  23. try:
  24. pid = int(line.split(None, 2)[1])
  25. os.kill(pid, 9)
  26. except OSError:
  27. pass
  28. return 0