Implement Redis shutdown broadcast for graceful daemon termination

Resolved 💬 2 comments Opened Dec 5, 2025 by maciejklimek Closed Dec 5, 2025

Problem

Currently, dashboard_server detects shutdown by checking if the Redis socket file disappeared. This is a workaround because:

  1. Uvicorn overrides signal handlers, so SIGTERM doesn't reach our code directly
  2. SSE connections keep uvicorn waiting during shutdown
  3. The pubsub listener keeps retrying Redis connections

Proposed Solution

Implement explicit shutdown broadcast via Redis:

  1. Launcher (Swift): Before calling supervisorctl shutdown, publish to speakeasy.shutdown channel
  2. Wait 100-200ms for daemons to receive the message
  3. All daemons: Subscribe to speakeasy.shutdown and trigger graceful shutdown when received

Benefits

  • Explicit signal vs inferring from socket disappearing
  • Works for all daemons, not just dashboard_server
  • Works in both TCP and socket Redis modes
  • Proper separation of concerns

Current Workaround

Dashboard server checks if Redis socket file exists after connection error. If socket is gone AND we've connected before, assume shutdown.

Files to modify

  • speakeasy/speakeasy_launcher/AppDelegate.swift - publish shutdown event
  • speakeasy/dashboard_server/server.py - subscribe to shutdown channel
  • Other daemons as needed

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗