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:
- Uvicorn overrides signal handlers, so SIGTERM doesn't reach our code directly
- SSE connections keep uvicorn waiting during shutdown
- The pubsub listener keeps retrying Redis connections
Proposed Solution
Implement explicit shutdown broadcast via Redis:
- Launcher (Swift): Before calling
supervisorctl shutdown, publish tospeakeasy.shutdownchannel - Wait 100-200ms for daemons to receive the message
- All daemons: Subscribe to
speakeasy.shutdownand 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 eventspeakeasy/dashboard_server/server.py- subscribe to shutdown channel- Other daemons as needed
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗