Browse Source

Merge pull request #906 from methane/falcon-disalbe-accesslog

falcon: Disable access log in meinheld.
mcocciaTE 11 years ago
parent
commit
8321c800bd
4 changed files with 42 additions and 23 deletions
  1. 20 0
      falcon/gunicorn_conf.py
  2. 8 7
      falcon/setup.py
  3. 2 6
      falcon/setup_py3.py
  4. 12 10
      falcon/setup_pypy.py

+ 20 - 0
falcon/gunicorn_conf.py

@@ -0,0 +1,20 @@
+import multiprocessing
+import sys
+
+_is_pypy = hasattr(sys, 'pypy_version_info')
+
+# falcon only implements json and plain. Not wait DB.
+workers = multiprocessing.cpu_count()
+bind = "0.0.0.0:8080"
+keepalive = 120
+
+if _is_pypy:
+    worker_class = "tornado"
+else:
+    worker_class = "meinheld.gmeinheld.MeinheldWorker"
+
+    def post_fork(server, worker):
+        # Disalbe access log
+        import meinheld.server
+        meinheld.server.set_access_logger(None)
+

+ 8 - 7
falcon/setup.py

@@ -1,9 +1,7 @@
 import subprocess
 import subprocess
-import multiprocessing
 import os
 import os
 
 
 bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/py2/bin')
 bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/py2/bin')
-NCPU = multiprocessing.cpu_count()
 
 
 proc = None
 proc = None
 
 
@@ -13,19 +11,22 @@ def start(args, logfile, errfile):
     proc = subprocess.Popen([
     proc = subprocess.Popen([
         bin_dir + "/gunicorn",
         bin_dir + "/gunicorn",
         "app:app",
         "app:app",
-        "-k", "meinheld.gmeinheld.MeinheldWorker",
-        "-b", "0.0.0.0:8080",
-        '-w', str(NCPU*3),
-        "--log-level=critical"],
+        "-c", "gunicorn_conf.py"],
         cwd="falcon", stderr=errfile, stdout=logfile)
         cwd="falcon", stderr=errfile, stdout=logfile)
     return 0
     return 0
 
 
 
 
 def stop(logfile, errfile):
 def stop(logfile, errfile):
+    global proc
+    if proc:
+        proc.terminate()
+        proc = None
+
     p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
     p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
     out, err = p.communicate()
     out, err = p.communicate()
     for line in out.splitlines():
     for line in out.splitlines():
       if 'FrameworkBenchmarks/installs/py2/bin/' in line:
       if 'FrameworkBenchmarks/installs/py2/bin/' in line:
-        pid = int(line.split(None,2)[1])
+        errfile.write("Killing: " + line + "\n")
+        pid = int(line.split()[1])
         os.kill(pid, 15)
         os.kill(pid, 15)
     return 0
     return 0

+ 2 - 6
falcon/setup_py3.py

@@ -1,9 +1,7 @@
 import subprocess
 import subprocess
-import multiprocessing
 import os
 import os
 
 
 bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/py3/bin')
 bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/py3/bin')
-NCPU = multiprocessing.cpu_count()
 
 
 proc = None
 proc = None
 
 
@@ -13,13 +11,11 @@ def start(args, logfile, errfile):
     proc = subprocess.Popen([
     proc = subprocess.Popen([
         bin_dir + "/gunicorn",
         bin_dir + "/gunicorn",
         "app:app",
         "app:app",
-        "-k", "meinheld.gmeinheld.MeinheldWorker",
-        "-b", "0.0.0.0:8080",
-        '-w', str(NCPU*3),
-        "--log-level=critical"],
+        "-c", "gunicorn_conf.py"],
         cwd="falcon", stderr=errfile, stdout=logfile)
         cwd="falcon", stderr=errfile, stdout=logfile)
     return 0
     return 0
 
 
+
 def stop(logfile, errfile):
 def stop(logfile, errfile):
     global proc
     global proc
     if proc is None:
     if proc is None:

+ 12 - 10
falcon/setup_pypy.py

@@ -1,9 +1,7 @@
 import subprocess
 import subprocess
-import multiprocessing
 import os
 import os
 
 
 bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/pypy/bin')
 bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/pypy/bin')
-NCPU = multiprocessing.cpu_count()
 
 
 proc = None
 proc = None
 
 
@@ -13,17 +11,21 @@ def start(args, logfile, errfile):
     proc = subprocess.Popen([
     proc = subprocess.Popen([
         bin_dir + "/gunicorn",
         bin_dir + "/gunicorn",
         "app:app",
         "app:app",
-        '-k', 'tornado',
-        "-b", "0.0.0.0:8080",
-        '-w', str(NCPU*3),
-        "--log-level=critical"],
+        "-c", "gunicorn_conf.py"],
         cwd="falcon", stderr=errfile, stdout=logfile)
         cwd="falcon", stderr=errfile, stdout=logfile)
     return 0
     return 0
 
 
 def stop(logfile, errfile):
 def stop(logfile, errfile):
     global proc
     global proc
-    if proc is None:
-        return 0
-    proc.terminate()
-    proc = None
+    if proc:
+        proc.terminate()
+        proc = None
+
+    p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+    out, err = p.communicate()
+    for line in out.splitlines():
+      if 'installs/pypy/bin/' in line:
+        errfile.write("Killing: " + line + "\n")
+        pid = int(line.split()[1])
+        os.kill(pid, 15)
     return 0
     return 0