setup_postgres.py 1.1 KB

1234567891011121314151617181920212223242526
  1. import subprocess
  2. import os
  3. import setup_util
  4. def start(args, logfile, errfile, cwd='wt'):
  5. setup_util.replace_text("wt/benchmark.cpp", "INSERT_DB_HOST_HERE", args.database_host);
  6. subprocess.check_call('g++-4.8 -O3 -DNDEBUG -DBENCHMARK_USE_POSTGRES -std=c++0x -L${BOOST_LIB} -I${BOOST_INC} -L${WT_LIB} -I${WT_INC} -o benchmark_postgres.wt benchmark.cpp -lwt -lwthttp -lwtdbo -lwtdbopostgres -lboost_thread', shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
  7. subprocess.Popen(['./benchmark_postgres.wt',
  8. '-c', 'wt_config.xml',
  9. '-t', str(args.max_threads),
  10. '--docroot', '.',
  11. '--http-address', '0.0.0.0',
  12. '--http-port', '8080',
  13. '--accesslog=-',
  14. '--no-compression'],
  15. cwd=cwd, stderr=errfile, stdout=logfile)
  16. return 0
  17. def stop(logfile, errfile):
  18. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  19. out, err = p.communicate()
  20. for line in out.splitlines():
  21. if 'benchmark_postgres.wt' in line:
  22. pid = int(line.split(None, 2)[1])
  23. os.kill(pid, 15)
  24. return 0