Replace GUNICORN_CMD_ARGS with custom LIGHTRAG_GUNICORN_MODE flag

• Use custom env var for mode detection
• Improve Gunicorn mode reliability
This commit is contained in:
yangdx 2025-10-29 14:06:03 +08:00
parent 816feefd84
commit 4a46d39c93
2 changed files with 4 additions and 2 deletions

View file

@ -328,8 +328,7 @@ def create_app(args):
# In Gunicorn mode with preload_app=True, cleanup is handled by worker_exit/on_exit hooks
# Only perform cleanup in Uvicorn single-process mode
if "GUNICORN_CMD_ARGS" not in os.environ:
if "LIGHTRAG_GUNICORN_MODE" not in os.environ:
# Clean up shared data
finalize_share_data()

View file

@ -34,6 +34,9 @@ def check_and_install_dependencies():
def main():
# Set Gunicorn mode flag for lifespan cleanup detection
os.environ["LIGHTRAG_GUNICORN_MODE"] = "1"
# Check .env file
if not check_env_file():
sys.exit(1)