Browse Source

tornado: don't use nginx.

INADA Naoki 12 years ago
parent
commit
67996f0a77
4 changed files with 6 additions and 84 deletions
  1. 0 1
      tornado/README.md
  2. 0 60
      tornado/deploy/nginx.conf
  3. 5 3
      tornado/server.py
  4. 1 20
      tornado/setup.py

+ 0 - 1
tornado/README.md

@@ -15,7 +15,6 @@ This is the Tornado portion of a [benchmarking test suite](../) comparing a vari
 The tests were run with:
 * [Python 2.7.3](http://www.python.org/)
 * [Tornado 3](https://www.tornadoweb.com/)
-* [nginx 1.4.0](http://nginx.org/)
 * [Mongodb 2.0.4](https://www.mongodb.org/)
 
 

+ 0 - 60
tornado/deploy/nginx.conf

@@ -1,60 +0,0 @@
-#user nginx;
-worker_processes 8;
-
-#error_log /var/log/nginx/error.log;
-#pid /var/run/nginx.pid;
-
-events {
-    worker_connections 8196;
-    accept_mutex off;
-    use epoll;
-}
-
-http {
-    # Enumerate all the Tornado servers here
-    upstream frontends {
-        server 127.0.0.1:8000;
-        server 127.0.0.1:8001;
-        server 127.0.0.1:8002;
-        server 127.0.0.1:8003;
-        server 127.0.0.1:8004;
-        server 127.0.0.1:8005;
-        server 127.0.0.1:8006;
-        server 127.0.0.1:8007;
-    }
-
-    include /usr/local/nginx/conf/mime.types;
-    default_type application/octet-stream;
-
-    # access_log /var/log/nginx/access.log;
-
-    keepalive_timeout 5;
-    proxy_read_timeout 200;
-    sendfile on;
-    tcp_nopush on;
-    tcp_nodelay on;
-    #gzip on;
-    #gzip_min_length 1000;
-    #gzip_proxied any;
-    #gzip_types text/plain text/html text/css text/xml
-    #           application/x-javascript application/xml
-    #           application/atom+xml text/javascript;
-
-    # Only retry if there was a communication error, not a timeout
-    # on the Tornado server (to avoid propagating "queries of death"
-    # to all frontends)
-    proxy_next_upstream error;
-
-    server {
-        listen 8080;
-
-        location / {
-            proxy_pass_header Server;
-            proxy_set_header Host $http_host;
-            proxy_redirect off;
-            proxy_set_header X-Real-IP $remote_addr;
-            proxy_set_header X-Scheme $scheme;
-            proxy_pass http://frontends;
-        }
-    }
-}

+ 5 - 3
tornado/server.py

@@ -6,13 +6,12 @@ import random
 from tornado import escape
 import tornado.options
 from tornado.options import options
+import tornado.httpserver
 
 
 tornado.options.define('port', default=8888, type=int, help=(
     "Server port"))
 
-db = motor.MotorClient("127.0.0.1").open_sync().hello_world
-
 class JsonSerializeTestHandler(tornado.web.RequestHandler):
     def get(self):
         obj = dict(message="Hello, World!")
@@ -49,5 +48,8 @@ application = tornado.web.Application([
 
 if __name__ == "__main__":
     tornado.options.parse_command_line()
-    application.listen(options.port)
+    server = tornado.httpserver.HTTPServer(application)
+    server.bind(options.port)
+    server.start(0)
+    db = motor.MotorClient("localhost").open_sync().hello_world
     tornado.ioloop.IOLoop.instance().start()

+ 1 - 20
tornado/setup.py

@@ -13,30 +13,11 @@ def start(args):
         cwd + "/server.py", "127.0.0.1", args.database_host)
 
     subprocess.check_call("sudo pip install -r requirements.txt", cwd=cwd, shell=True)
-
-    subprocess.Popen("python %s/FrameworkBenchmarks/tornado/server.py --port=8000 --logging=error" % home, shell=True, cwd=cwd)
-    subprocess.Popen("python %s/FrameworkBenchmarks/tornado/server.py --port=8001 --logging=error" % home, shell=True, cwd=cwd)
-    subprocess.Popen("python %s/FrameworkBenchmarks/tornado/server.py --port=8002 --logging=error" % home, shell=True, cwd=cwd)
-    subprocess.Popen("python %s/FrameworkBenchmarks/tornado/server.py --port=8003 --logging=error" % home, shell=True, cwd=cwd)
-    subprocess.Popen("python %s/FrameworkBenchmarks/tornado/server.py --port=8004 --logging=error" % home, shell=True, cwd=cwd)
-    subprocess.Popen("python %s/FrameworkBenchmarks/tornado/server.py --port=8005 --logging=error" % home, shell=True, cwd=cwd)
-    subprocess.Popen("python %s/FrameworkBenchmarks/tornado/server.py --port=8006 --logging=error" % home, shell=True, cwd=cwd)
-    subprocess.Popen("python %s/FrameworkBenchmarks/tornado/server.py --port=8007 --logging=error" % home, shell=True, cwd=cwd)
-    subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/tornado/deploy/nginx.conf", shell=True)
-
+    subprocess.Popen("python %s/FrameworkBenchmarks/tornado/server.py --port=8080 --logging=error" % home, shell=True, cwd=cwd)
     return 0
 
 
 def stop():
-
-    try:
-
-        subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True)
-
-    except subprocess.CalledProcessError:
-        #TODO: Better handle exception.
-        pass
-
     p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
     out, err = p.communicate()
     for line in out.splitlines():