|
@@ -1,24 +1,30 @@
|
|
-import subprocess
|
|
|
|
-import setup_util
|
|
|
|
from os.path import expanduser
|
|
from os.path import expanduser
|
|
from os import kill
|
|
from os import kill
|
|
|
|
+import subprocess
|
|
|
|
+import sys
|
|
|
|
+import time
|
|
|
|
+
|
|
|
|
|
|
python = expanduser('~/FrameworkBenchmarks/installs/py2/bin/python')
|
|
python = expanduser('~/FrameworkBenchmarks/installs/py2/bin/python')
|
|
cwd = expanduser('~/FrameworkBenchmarks/tornado')
|
|
cwd = expanduser('~/FrameworkBenchmarks/tornado')
|
|
|
|
|
|
|
|
|
|
def start(args, logfile, errfile):
|
|
def start(args, logfile, errfile):
|
|
- setup_util.replace_text(
|
|
|
|
- cwd + "/server.py", "localhost", args.database_host)
|
|
|
|
-
|
|
|
|
subprocess.Popen(
|
|
subprocess.Popen(
|
|
- python + " server.py --port=8080 --logging=error",
|
|
|
|
|
|
+ python + " server.py --port=8080 --mongo=%s --logging=error" % (args.database_host,),
|
|
shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
|
|
shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
|
|
return 0
|
|
return 0
|
|
|
|
|
|
def stop(logfile, errfile):
|
|
def stop(logfile, errfile):
|
|
- for line in subprocess.check_output("ps aux"):
|
|
|
|
- if 'FrameworkBenchmarks/installs/py2/bin/python server.py --port=8080 --logging=error' in line:
|
|
|
|
|
|
+ for line in subprocess.check_output(["ps", "aux"]).splitlines():
|
|
|
|
+ if 'server.py --port=8080' in line:
|
|
pid = int(line.split(None,2)[1])
|
|
pid = int(line.split(None,2)[1])
|
|
kill(pid, 9)
|
|
kill(pid, 9)
|
|
return 0
|
|
return 0
|
|
|
|
+
|
|
|
|
+if __name__ == '__main__':
|
|
|
|
+ class DummyArg:
|
|
|
|
+ database_host = 'localhost'
|
|
|
|
+ start(DummyArg(), sys.stderr, sys.stderr)
|
|
|
|
+ time.sleep(1)
|
|
|
|
+ stop(sys.stderr, sys.stderr)
|