From 7cd8f26c374236f9e010ad14ef7cb2c1aad05cfd Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 23 Feb 2026 17:38:01 -0600 Subject: [PATCH] Fix double startup: remove startup_event from Hypercorn hooks startup_event was registered as a Hypercorn startup hook AND called manually in run_server_with_startup(), causing it to execute twice. The second execution blocked the server from accepting connections until vector init completed again. Co-Authored-By: Claude Opus 4.6 --- main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 0d037e8..5ab334f 100644 --- a/main.py +++ b/main.py @@ -155,8 +155,9 @@ if __name__ == '__main__': # It's safer to configure these via a reverse proxy (like Nginx) in production. # Hypercorn's defaults are usually reasonable. Let's comment these out for now. - # Assign startup and shutdown handlers - config.startup_hooks = [startup_event] + # Shutdown handler only — startup is handled manually in run_server_with_startup() + # so we can launch GraphRAG as a background task in the same event loop. + # Do NOT register startup_event as a hook here (it would run twice). config.shutdown_hooks = [shutdown_event] log_structured('info', f"Starting Hypercorn server on {SERVER_HOST}:{SERVER_PORT}")