Describe the Bug
When Docker/K8s sends SIGTERM to backend, process exits immediately without finishing in-flight requests or closing database connections, causing usage event data loss.
Steps to Reproduce
- Start backend with active MQTT message processing
- Send SIGTERM:
docker stop container
- Process exits immediately
- In-flight usage updates lost
- Database connections not closed properly
Expected Behavior
Implement graceful shutdown:
- Stop accepting new requests
- Finish processing in-flight requests (max 30s)
- Close MQTT connection
- Close database connections
- Exit with code 0
Actual Behavior
Immediate exit, potential data loss.
Environment
| Field |
Value |
| Component |
backend |
| OS |
Ubuntu 22.04 (Docker) |
| Network |
testnet |
Describe the Bug
When Docker/K8s sends SIGTERM to backend, process exits immediately without finishing in-flight requests or closing database connections, causing usage event data loss.
Steps to Reproduce
docker stop containerExpected Behavior
Implement graceful shutdown:
Actual Behavior
Immediate exit, potential data loss.
Environment