Browse Source

Fix tornado doesn't shutdown.

INADA Naoki 11 years ago
parent
commit
4a3107026c
3 changed files with 15 additions and 20 deletions
  1. 5 6
      tornado/setup.py
  2. 5 7
      tornado/setup_py3.py
  3. 5 7
      tornado/setup_pypy.py

+ 5 - 6
tornado/setup.py

@@ -6,6 +6,7 @@ from os import kill
 python = expanduser('~/FrameworkBenchmarks/installs/py2/bin/python')
 cwd = expanduser('~/FrameworkBenchmarks/tornado')
 
+
 def start(args, logfile, errfile):
     setup_util.replace_text(
         cwd + "/server.py", "localhost", args.database_host)
@@ -16,10 +17,8 @@ def start(args, logfile, errfile):
     return 0
 
 def stop(logfile, errfile):
-    p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-    out, err = p.communicate()
-    for line in out.splitlines():
-      if 'FrameworkBenchmarks/installs/py2/bin/python server.py --port=8080 --logging=error' in line:
-        pid = int(line.split(None,2)[1])
-        kill(pid, 9)
+    for line in subprocess.check_output("ps aux"):
+        if 'FrameworkBenchmarks/installs/py2/bin/python server.py --port=8080 --logging=error' in line:
+            pid = int(line.split(None,2)[1])
+            kill(pid, 9)
     return 0

+ 5 - 7
tornado/setup_py3.py

@@ -4,22 +4,20 @@ from os.path import expanduser
 
 python = expanduser('~/FrameworkBenchmarks/installs/py3/bin/python3')
 cwd = expanduser('~/FrameworkBenchmarks/tornado')
-proc = None
 
 
 def start(args, logfile, errfile):
-    global proc
     setup_util.replace_text(
         cwd + "/server.py", "localhost", args.database_host)
 
-    proc = subprocess.Popen(
+    subprocess.Popen(
         python + " server.py --port=8080 --logging=error",
         shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
     return 0
 
 def stop(logfile, errfile):
-    global proc
-    if proc:
-        proc.terminate()
-        proc = None
+    for line in subprocess.check_output("ps aux"):
+        if "installs/py3/bin/python3" in line:
+            pid = int(line.split(None,2)[1])
+            os.kill(pid, 9)
     return 0

+ 5 - 7
tornado/setup_pypy.py

@@ -4,22 +4,20 @@ from os.path import expanduser
 
 python = expanduser('~/FrameworkBenchmarks/installs/pypy/bin/pypy')
 cwd = expanduser('~/FrameworkBenchmarks/tornado')
-proc = None
 
 
 def start(args, logfile, errfile):
-    global proc
     setup_util.replace_text(
         cwd + "/server.py", "localhost", args.database_host)
 
-    proc = subprocess.Popen(
+    subprocess.Popen(
         python + " server.py --port=8080 --logging=error",
         shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
     return 0
 
 def stop(logfile, errfile):
-    global proc
-    if proc:
-        proc.terminate()
-        proc = None
+    for line in subprocess.check_output("ps aux"):
+        if "installs/pypy/bin/pypy" in line:
+            pid = int(line.split(None,2)[1])
+            os.kill(pid, 9)
     return 0