setup_unfiltered.py 994 B

123456789101112131415161718192021222324252627282930
  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("../sbt/sbt assembly", shell=True, cwd="unfiltered")
  15. subprocess.Popen("java -jar bench-assembly-1.0.0.jar", stderr=DEVNULL, shell=True, cwd="unfiltered/target/scala-2.10")
  16. return 0
  17. def stop():
  18. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  19. out, err = p.communicate()
  20. for line in out.splitlines():
  21. if 'bench-assembly' in line or 'java' in line:
  22. pid = int(line.split(None, 2)[1])
  23. os.kill(pid, 9)
  24. return 0