Skip to content

Commit

Permalink
adding aliase guncornGevent
Browse files Browse the repository at this point in the history
  • Loading branch information
ali96343 committed Oct 25, 2023
1 parent a9f9200 commit 3fb7169
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions py4web/server_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

__all__ = [
"gunicorn",
"gunicornGevent",
"gevent",
"geventWebSocketServer",
"geventWs", # short_name
Expand Down Expand Up @@ -126,6 +127,8 @@ class GunicornServer(ServerAdapter):
""" https://docs.gunicorn.org/en/stable/settings.html """
# https://pawamoy.github.io/posts/unify-logging-for-a-gunicorn-uvicorn-app/
# ./py4web.py run apps -s gunicorn --watch=off --port=8000 --ssl_cert=cert.pem --ssl_key=key.pem -w 6 -Q
#
# ./py4web.py run apps -s gunicornGevent --watch=off --port=8000 --ssl_cert=cert.pem --ssl_key=key.pem -w 6 -Q

def run(self, app_handler):
from gunicorn.app.base import BaseApplication
Expand Down Expand Up @@ -158,13 +161,16 @@ def load_config(self):
# export GUNICORN_WORKERS=2
# export GUNICORN_BACKLOG=4096

# To use gevent monkey.patch_all() , run ./py4web.py run apps -s gunicornGevent ......
# export GUNICORN_worker_class=gevent
# export GUNICORN_worker_class=gunicorn.workers.ggevent.GeventWorker

gunicorn_vars = dict()

for k,v in os.environ.items():
if k.startswith("GUNICORN_"):
if k.startswith("GUNICORN_") and v:
key = k.split('_', 1)[1].lower()
if v:
gunicorn_vars[key] = v
gunicorn_vars[key] = v

if gunicorn_vars:
config.update( gunicorn_vars )
Expand All @@ -178,6 +184,7 @@ def load(self):

GunicornApplication().run()
return GunicornServer
gunicornGevent = gunicorn



Expand Down

0 comments on commit 3fb7169

Please sign in to comment.