From 2de592f798f0e4e834c7ebaaf037df89d9826a13 Mon Sep 17 00:00:00 2001 From: Smittix Date: Sat, 28 Feb 2026 21:31:01 +0000 Subject: [PATCH] fix: suppress noisy gevent SystemExit traceback on shutdown When stopping gunicorn with Ctrl+C, the gevent worker's handle_quit() calls sys.exit(0) inside a greenlet, causing gevent to print a SystemExit traceback. Add a gunicorn config with post_worker_init hook that marks SystemExit as a non-error in gevent's hub. Co-Authored-By: Claude Opus 4.6 --- gunicorn.conf.py | 18 ++++++++++++++++++ start.sh | 1 + 2 files changed, 19 insertions(+) create mode 100644 gunicorn.conf.py diff --git a/gunicorn.conf.py b/gunicorn.conf.py new file mode 100644 index 0000000..dae09bd --- /dev/null +++ b/gunicorn.conf.py @@ -0,0 +1,18 @@ +"""Gunicorn configuration for INTERCEPT.""" + + +def post_worker_init(worker): + """Suppress noisy SystemExit tracebacks during gevent worker shutdown. + + When gunicorn receives SIGINT, the gevent worker's handle_quit() + calls sys.exit(0) inside a greenlet. Gevent treats SystemExit as + an error by default and prints a traceback. Adding it to NOT_ERROR + silences this harmless noise. + """ + try: + from gevent import get_hub + hub = get_hub() + if SystemExit not in hub.NOT_ERROR: + hub.NOT_ERROR = hub.NOT_ERROR + (SystemExit,) + except Exception: + pass diff --git a/start.sh b/start.sh index 567bcba..85e9922 100755 --- a/start.sh +++ b/start.sh @@ -126,6 +126,7 @@ if [[ "$HAS_GUNICORN" -eq 1 && "$HAS_GEVENT" -eq 1 ]]; then echo "[INTERCEPT] Listening on ${HOST}:${PORT}" GUNICORN_ARGS=( + -c "$SCRIPT_DIR/gunicorn.conf.py" -k gevent -w 1 --timeout 300