2022-05-20 15:24:51 +00:00
|
|
|
import logging
|
2021-04-01 09:38:18 +00:00
|
|
|
import multiprocessing
|
2021-07-29 06:37:34 +00:00
|
|
|
import os
|
|
|
|
|
2021-07-29 13:44:52 +00:00
|
|
|
logger = logging.getLogger('inventree')
|
2021-07-29 06:37:34 +00:00
|
|
|
|
|
|
|
workers = os.environ.get('INVENTREE_GUNICORN_WORKERS', None)
|
|
|
|
|
|
|
|
if workers is not None:
|
|
|
|
try:
|
|
|
|
workers = int(workers)
|
|
|
|
except ValueError:
|
|
|
|
workers = None
|
|
|
|
|
|
|
|
if workers is None:
|
|
|
|
workers = multiprocessing.cpu_count() * 2 + 1
|
|
|
|
|
|
|
|
logger.info(f"Starting gunicorn server with {workers} workers")
|
2021-04-01 09:38:18 +00:00
|
|
|
|
|
|
|
max_requests = 1000
|
|
|
|
max_requests_jitter = 50
|