setup.py 994 B

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