setup.py 837 B

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