I'll add a little, PR823
1 It's possible put gunicorn variables to
the py4web/gunicorn.saenv
example py4web/gunicorn.saenv
----------------------------------------------------------------------------
# export GUNICORN_max_requests=1200
export GUNICORN_worker_tmp_dir=/dev/shm
# print working gunicorn config
print_config=True
# None test
certfile=None
# dict test
secure_scheme_headers = {'x1':'y1','X-FORWARDED-PROTOCOL': 'ssl', }
# the variable 'bind' will be ignored, use ./py4web.py ... -H -P
bind=
128.0.0.1:9000# skip empty key, empty key is comment
gunicornGevent
#worker_class=gevent
#worker_class=eventlet
# it's comment
[hello any text]
-------------------------------------------------------------
2 gunicorn variables can be loaded from python-file or python-module
2.1 set the variable 'use_native_config'
through environment:
export GUNCORN_use_native_config=myconf.py
or file or py4web/gunicorn.saenv:
---------------------------------------
# py4web/gunicorn.saenv
# load conf from python-module or python-file
# example - python module
# cd py4web && mkdir example && touch myexample/__ini__.py
use_native_config=python:myexample
# or
use_native_config=
gunicorn.conf.py# variables other than use_native_config will be ignored
----------------------------------------
2.2 Write a python module or python file with config
2.3./py4web.py run apps -s gunicorn.....
2.4 An interesting example of a config here
https://github.com/benoitc/gunicorn/blob/master/examples/example_config.py
3. It is also possible to run gunicorn using
the usual classical cli-method
https://groups.google.com/g/py4web/c/1kKYnxLsTmY/m/_Bf4IdyECwAJ3.1
# py4web/py4web_wsgi.py
from py4web.core import wsgi
myapp = wsgi(apps_folder="apps")
#then start using gunicorn-cli
$ gunicorn -w 4 py4web_wsgi:myapp
4. sometimes it's hard to stop gunicorn master and workers
I'm using
pkill -x gunicorn
for i in {1..100}; do pkill -f gunicorn ; done
5. some comands from .bashrc
export PY4WEB_LOGS=/tmp
p4w_path=~/HOME/xxxxxx/py4web
alias aguni="cd $p4w_path && ./py4web.py run apps -s gunicorn --watch=off --port=8000 --ssl_cert=cert.pem --ssl_key=key.pem -w 6 -L 20"
alias ghuni="cd $p4w_path && ./py4web.py run apps -s gunicornGevent --watch=off --port=8000 --ssl_cert=cert.pem --ssl_key=key.pem -w 6 -L 20"
6 info-link