summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIuri de Silvio <iurisilvio@gmail.com>2011-09-17 12:12:55 -0300
committerIuri de Silvio <iurisilvio@gmail.com>2011-09-17 12:12:55 -0300
commit664894634dccfef549a2f83e7dd5e40bacbb35f6 (patch)
tree4e476c802eb5baa6486aa041320363ad4fa2a601
parent83523de755f9c428cb6a6944693ea0d8fd5d580e (diff)
downloadbottle-664894634dccfef549a2f83e7dd5e40bacbb35f6.tar.gz
Update GunicornServer, based on Itty implementation.
-rwxr-xr-xbottle.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/bottle.py b/bottle.py
index f16f4dd..f0e7262 100755
--- a/bottle.py
+++ b/bottle.py
@@ -2074,11 +2074,27 @@ class GeventServer(ServerAdapter):
class GunicornServer(ServerAdapter):
""" Untested. """
def run(self, handler):
- from gunicorn.arbiter import Arbiter
- from gunicorn.config import Config
- handler.cfg = Config({'bind': "%s:%d" % (self.host, self.port), 'workers': 4})
- arbiter = Arbiter(handler)
- arbiter.run()
+ from gunicorn import version_info
+
+ config = {'bind': "%s:%d" % (self.host, int(self.port)), 'workers': 4}
+
+ if version_info < (0, 9, 0):
+ from gunicorn.arbiter import Arbiter
+ from gunicorn.config import Config
+
+ arbiter = Arbiter(Config(config), app())
+ arbiter.run()
+ else:
+ from gunicorn.app.base import Application
+
+ class GunicornApplication(Application):
+ def init(_self, parser, opts, args):
+ return config
+
+ def load(self):
+ return app()
+
+ GunicornApplication().run()
class EventletServer(ServerAdapter):