Implement notification system that works even when database is unavailable. Problem: - When Uptime Kuma's database (external MariaDB/SQLite) becomes unavailable, UK stops functioning and cannot send notifications about its own failure. - Users are not alerted when UK itself is having database connectivity issues. Solution: - Added notification cache system that stores all active notification configs in memory when database is available - Implemented database error detection in both monitor.js and server.js error handlers to catch EHOSTUNREACH, ECONNREFUSED, and other DB errors - Added sendDatabaseDownNotification() method that uses cached notifications to send alerts when database connection fails - Cache automatically refreshes periodically (every 30 minutes) and when notifications are added/updated/deleted - Prevents duplicate notifications for the same database down event Changes: - server/notification.js: Added cache system and database down notification - server/server.js: Enhanced error handler to detect DB errors and trigger notifications, refresh cache on startup - server/model/monitor.js: Added DB error detection in safeBeat error handler - server/jobs.js: Added periodic cache refresh job (every 30 minutes) - test/backend-test/test-database-down-notification.js: Comprehensive test suite covering cache, notifications, error handling This ensures users are always notified when UK itself is having database connectivity issues, even if the database is completely unavailable. |
||
|---|---|---|
| .. | ||
| api_key.js | ||
| docker_host.js | ||
| domain_expiry.js | ||
| group.js | ||
| heartbeat.js | ||
| incident.js | ||
| maintenance.js | ||
| monitor.js | ||
| proxy.js | ||
| remote_browser.js | ||
| status_page.js | ||
| tag.js | ||
| user.js | ||