More work on configs and env

This commit is contained in:
Scott Idem
2023-09-08 14:23:08 -04:00
parent be1bb21b7e
commit 9262e9987e
3 changed files with 20 additions and 12 deletions

View File

@@ -93,8 +93,11 @@ AE_SMTP_USERNAME=send_mail
AE_API_ENV=development
AE_API_DIR=/srv/aether_api
AE_API_LOG_PATH="/logs/aether_api.log"
AE_API_WORKERS=2
AE_API_THREADS=1
AE_API_GUNICORN_TIMEOUT=2100 # (default=30; should be much higher)
AE_API_GUNICORN_GRACEFUL_TIMEOUT=30 # (default=30)
AE_API_GUNICORN_KEEPALIVE=30 # (default=2)
AE_API_GUNICORN_WORKERS=2 # (default=2)
AE_API_GUNICORN_THREADS=2 # (default=2)
AE_API_RELOAD=False
AE_API_JWT_KEY="ABC123 22 CHARS" # 22 characters; super secret Aether JWT signing key
@@ -108,6 +111,11 @@ AE_APP_DIR=/srv/aether_app
AE_APP_LOG_PATH="/logs/aether_app.log"
AE_APP_WORKERS=2
AE_APP_THREADS=1
AE_APP_GUNICORN_TIMEOUT=1200 # (default=30; should be higher)
AE_APP_GUNICORN_GRACEFUL_TIMEOUT=20 # (default=30)
AE_APP_GUNICORN_KEEPALIVE=30 # (default=2)
AE_APP_GUNICORN_WORKERS=2 # (default=2)
AE_APP_GUNICORN_THREADS=1 # (default=1)
AE_APP_RELOAD=True
# Generate a new key with: # python -c 'import os; print(os.urandom(16))'
AE_APP_CACHE_SECRET_KEY="$\x93\x12\xb4R\x80R\xb5\xe50\xa0k\xc8#RN"

View File

@@ -22,9 +22,9 @@ wsgi_app = "app.main:app"
# default_proc_name = "app.main:app"
# Setting a long timeout since some FastAPI API requests may take a while
timeout = 2100 # default 30; 1200 is NOT enough; worker process silent then kill and restart
graceful_timeout = 20 # default 30; timeout after restart signal; tried 10 2023-07-11
keepalive = 30 # default 2; setting higher because behind load balancer (nginx); tried 10 2023-07-11
timeout = os.getenv('AE_API_GUNICORN_TIMEOUT', 2100) # default 30; 1200 is NOT enough; worker process silent then kill and restart
graceful_timeout = os.getenv('AE_API_GUNICORN_GRACEFUL_TIMEOUT', 20) # default 30; timeout after restart signal; tried 10 2023-07-11
keepalive = os.getenv('AE_API_GUNICORN_KEEPALIVE', 30) # default 2; setting higher because behind load balancer (nginx); tried 10 2023-07-11
# Reload does not work correctly with UvicornWorker
# https://github.com/benoitc/gunicorn/issues/2339
@@ -37,7 +37,7 @@ worker_class = "uvicorn.workers.UvicornWorker" # default "sync"
# Works are processes, not threads
# workers = 9 # default 1; use 10ish for production; 2 to 4 times the number of cores
# threads = 1 # default 1; only affects Gthread worker type
workers = os.getenv('AE_API_WORKERS', 2)
threads = os.getenv('AE_API_THREADS', 2)
workers = os.getenv('AE_API_GUNICORN_WORKERS', 2)
threads = os.getenv('AE_API_GUNICORN_THREADS', 2)
# umask = '007'

View File

@@ -22,9 +22,9 @@ wsgi_app = "run_server:app"
# default_proc_name = "run_server:app"
# Setting a longer timeout since some Flask app requests may take a while
timeout = 1200 # default 30; worker process silent then kill and restart
graceful_timeout = 20
keepalive = 300 # default 2; setting higher because behind load balancer (nginx)
timeout = os.getenv('AE_APP_GUNICORN_TIMEOUT', 1200) # default 30; worker process silent then kill and restart
graceful_timeout = os.getenv('AE_APP_GUNICORN_GRACEFUL_TIMEOUT', 20)
keepalive = os.getenv('AE_APP_GUNICORN_KEEPALIVE', 300) # default 2; setting higher because behind load balancer (nginx)
# Disable reload if using more than one thread
reload = True
@@ -33,8 +33,8 @@ reload = True
# Works are processes, not threads
# workers = 9 # default 1; use 10ish for production; 2 to 4 times the number of cores
# threads = 1 # default 1; only affects Gthread worker type
workers = os.getenv('AE_APP_WORKERS', 2)
threads = os.getenv('AE_APP_THREADS', 2)
workers = os.getenv('AE_APP_GUNICORN_WORKERS', 2)
threads = os.getenv('AE_APP_GUNICORN_THREADS', 2)
# umask = '007'