setup.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. 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. else:
  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, 15)
  26. except OSError:
  27. return 1
  28. # Takes up so much disk space
  29. if os.name == 'nt':
  30. subprocess.check_call("del /f /s /q target && del /f /s /q project", shell=True, cwd="plain", stderr=errfile, stdout=logfile)
  31. else:
  32. subprocess.check_call("rm -rf target && rm -rf project/.ivy && rm -rf project/.boot", shell=True, cwd="plain", stderr=errfile, stdout=logfile)
  33. return 0