setup.py 846 B

123456789101112131415161718192021222324252627282930
  1. from os.path import expanduser
  2. from os import kill
  3. import subprocess
  4. import sys
  5. import time
  6. python = expanduser('~/FrameworkBenchmarks/installs/py2/bin/python')
  7. cwd = expanduser('~/FrameworkBenchmarks/tornado')
  8. def start(args, logfile, errfile):
  9. subprocess.Popen(
  10. python + " server.py --port=8080 --mongo=%s --logging=error" % (args.database_host,),
  11. shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
  12. return 0
  13. def stop(logfile, errfile):
  14. for line in subprocess.check_output(["ps", "aux"]).splitlines():
  15. if 'server.py --port=8080' in line:
  16. pid = int(line.split(None,2)[1])
  17. kill(pid, 9)
  18. return 0
  19. if __name__ == '__main__':
  20. class DummyArg:
  21. database_host = 'localhost'
  22. start(DummyArg(), sys.stderr, sys.stderr)
  23. time.sleep(1)
  24. stop(sys.stderr, sys.stderr)