setup.py 880 B

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