setup.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 -jar target/scala-2.10/plain-benchmark-assembly-1.0.1.jar", cwd="plain", shell=True, stderr=errfile, stdout=logfile)
  13. return 0
  14. def stop(logfile, errfile):
  15. if os.name == 'nt':
  16. subprocess.call("taskkill /f /im *plain-benchmark* > NUL", shell=True, stderr=errfile, stdout=logfile)
  17. else:
  18. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  19. out, err = p.communicate()
  20. for line in out.splitlines():
  21. if 'plain-benchmark' in line:
  22. try:
  23. pid = int(line.split(None, 2)[1])
  24. os.kill(pid, 15)
  25. except OSError:
  26. return 1
  27. # Takes up so much disk space
  28. if os.name == 'nt':
  29. subprocess.check_call("del /f /s /q target && del /f /s /q project", shell=True, cwd="plain", stderr=errfile, stdout=logfile)
  30. else:
  31. subprocess.check_call("rm -rf target && rm -rf project/.ivy && rm -rf project/.boot", shell=True, cwd="plain", stderr=errfile, stdout=logfile)
  32. return 0