Modify: replace gunicorn to gunicorn async add gunicorn config file

This commit is contained in:
Stepan Zhukovsky 2023-08-31 20:53:10 +09:00
parent 790be86f13
commit 7963e2fad5
5 changed files with 52 additions and 4 deletions

View File

@ -3,4 +3,4 @@
python manage.py migrate --no-input
python manage.py collectstatic --no-input
gunicorn logs_collector.wsgi:application --bind 0.0.0.0:8000
gunicorn logs_collector.wsgi:application

View File

@ -0,0 +1,48 @@
import environ
import gunicorn
from logs_collector.settings import BASE_DIR
# █▀▀ █░█ █▄░█ █ █▀▀ █▀█ █▀█ █▄░█ █▀▀ █▀█ █▄░█ █▀▀ █ █▀▀ ▀
# █▄█ █▄█ █░▀█ █ █▄▄ █▄█ █▀▄ █░▀█ █▄▄ █▄█ █░▀█ █▀░ █ █▄█ ▄
# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# https://docs.gunicorn.org/en/stable/settings.html
# https://github.com/benoitc/gunicorn/blob/master/examples/example_config.py
# hide web server name:
gunicorn.SERVER = 'undisclosed'
env = environ.Env(
# set casting, default value:
GUNICORN_BIND=(str, '0.0.0.0:8000'),
GUNICORN_BACKLOG=(int, 2048),
GUNICORN_WORKERS=(int, 2),
GUNICORN_WORKER_CLASS=(str, 'gthread'),
GUNICORN_WORKER_CONNECTIONS=(int, 1000),
GUNICORN_THREADS=(int, 1),
GUNICORN_TIMEOUT=(int, 30),
GUNICORN_KEEPALIVE=(int, 2),
GUNICORN_LOGLEVEL=(str, 'info'),
)
environ.Env.read_env(BASE_DIR / '.env')
# Server socket:
bind = env('GUNICORN_BIND')
backlog = env('GUNICORN_BACKLOG')
# Worker processes:
workers = env('GUNICORN_WORKERS')
worker_class = env('GUNICORN_WORKER_CLASS')
worker_connections = env('GUNICORN_WORKER_CONNECTIONS')
threads = env('GUNICORN_THREADS')
timeout = env('GUNICORN_TIMEOUT')
keepalive = env('GUNICORN_KEEPALIVE')
# Logging:
loglevel = env('GUNICORN_LOGLEVEL')
errorlog = '-'
accesslog = '-'
access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"' # noqa:E501

2
poetry.lock generated
View File

@ -727,4 +727,4 @@ brotli = ["Brotli"]
[metadata]
lock-version = "2.0"
python-versions = "^3.10"
content-hash = "39c4da284ce6727245ff8e62ae325111cccd55175f38bc34045cbf2ef153d871"
content-hash = "e67fb8ed8bd9086956f4c789fd42d8b0ebe140579bc2aa2f1c303bd1def9b2f7"

View File

@ -20,7 +20,7 @@ django-filter = "23.2"
drf-spectacular = "0.26.4"
django-two-factor-auth = {extras = ["phonenumberslite"], version = "1.15.3"}
whitenoise = "6.5.0"
gunicorn = "21.2.0"
gunicorn = {extras = ["gthread"], version = "21.2.0"}
[tool.poetry.group.dev.dependencies]
flake8 = "^6.0.0"

View File

@ -46,7 +46,7 @@ djangorestframework==3.14.0 ; python_version >= "3.10" and python_version < "4.0
drf-spectacular==0.26.4 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:8f5a8f87353d1bb8dcb3f3909b7109b2dcbe1d91f3e069409cf322963e140bd6 \
--hash=sha256:afeccc6533dcdb4e78afbfcc49f3c5e9c369aeb62f965e4d1a43b165449c147a
gunicorn==21.2.0 ; python_version >= "3.10" and python_version < "4.0" \
gunicorn[gthread]==21.2.0 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:3213aa5e8c24949e792bcacfc176fef362e7aac80b76c56f6b5122bf350722f0 \
--hash=sha256:88ec8bff1d634f98e61b9f65bc4bf3cd918a90806c6f5c48bc5603849ec81033
inflection==0.5.1 ; python_version >= "3.10" and python_version < "4.0" \