setup.py 866 B

123456789101112131415161718192021222324252627
  1. import subprocess
  2. import sys
  3. import setup_util
  4. import os
  5. def start(args):
  6. setup_util.replace_text("snap/bench/cfg/db.cfg", "host=\".*\"", "host=\"" + args.database_host + "\"")
  7. subprocess.check_call("cabal update", shell=True, cwd="snap/bench")
  8. subprocess.check_call("cabal install --only-dependencies", shell=True, cwd="snap/bench")
  9. subprocess.check_call("cabal build", shell=True, cwd="snap/bench")
  10. t = str(args.max_threads)
  11. subprocess.Popen("dist/build/snap-bench/snap-bench +RTS -A" + t + "M -N" + t + " > /dev/null", shell=True, cwd="snap/bench")
  12. return 0
  13. def stop():
  14. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  15. out, err = p.communicate()
  16. for line in out.splitlines():
  17. if 'snap-bench' in line:
  18. try:
  19. pid = int(line.split(None, 2)[1])
  20. os.kill(pid, 9)
  21. except OSError:
  22. pass
  23. return 0