setup_unfiltered.py 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. import subprocess
  2. import sys
  3. import setup_util
  4. import os
  5. def start(args):
  6. setup_util.replace_text("unfiltered/src/main/resources/application.conf", "jdbc:mysql:\/\/.*:3306", "jdbc:mysql://" + args.database_host + ":3306")
  7. setup_util.replace_text("unfiltered/src/main/resources/application.conf", "maxThreads = \\d+", "maxThreads = " + str(args.max_threads))
  8. # Shamelessly stolen from stack overflow
  9. try:
  10. from subprocess import DEVNULL
  11. except ImportError:
  12. import os
  13. DEVNULL = open(os.devnull, 'wb')
  14. subprocess.check_call("chmod u+x sbt", shell=True, cwd="unfiltered")
  15. subprocess.check_call("./sbt assembly", shell=True, cwd="unfiltered")
  16. subprocess.Popen("java -jar bench-assembly-1.0.0.jar", stderr=DEVNULL, shell=True, cwd="unfiltered/target/scala-2.10")
  17. return 0
  18. def stop():
  19. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  20. out, err = p.communicate()
  21. for line in out.splitlines():
  22. if 'bench-assembly' in line or 'java' in line:
  23. pid = int(line.split(None, 2)[1])
  24. os.kill(pid, 9)
  25. return 0