setup.py 849 B

123456789101112131415161718192021222324252627
  1. import subprocess
  2. import os
  3. def start(args, logfile, errfile):
  4. subprocess.check_call("urweb bench", shell=True, cwd="UrWeb", stderr=errfile, stdout=logfile)
  5. threads = str(args.max_threads)
  6. conn_string = ('dbname=hello_world '
  7. 'user=benchmarkdbuser '
  8. 'password=benchmarkdbpass '
  9. 'host=' + args.database_host)
  10. env = {'URWEB_PQ_CON': conn_string}
  11. subprocess.Popen("./bench.exe -t " + threads,
  12. env=env, shell=True, cwd="UrWeb", stderr=errfile, stdout=logfile)
  13. return 0
  14. def stop(logfile, errfile):
  15. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  16. out, err = p.communicate()
  17. for line in out.splitlines():
  18. if 'bench.exe' 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