uptime-kuma/server/model
SmartDever02 942fd5021c fix: send notifications when UK database is down (#6498)
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.
2026-01-06 03:00:34 +01:00
..
api_key.js Added JSDoc to ESLint (#3529) 2023-08-11 15:46:41 +08:00
docker_host.js Added JSDoc to ESLint (#3529) 2023-08-11 15:46:41 +08:00
domain_expiry.js fix imports 2026-01-01 16:34:05 +01:00
group.js Add a public URL field for monitors and uses it on the status page (#5435) 2025-05-10 19:05:37 +02:00
heartbeat.js Feat: Retries persistence (#3814) 2023-11-24 18:11:36 +08:00
incident.js Added JSDoc to ESLint (#3529) 2023-08-11 15:46:41 +08:00
maintenance.js fix: MariaDB datetime format error when pausing maintenance (#6513) 2025-12-22 14:32:12 +01:00
monitor.js fix: send notifications when UK database is down (#6498) 2026-01-06 03:00:34 +01:00
proxy.js Added JSDoc to ESLint (#3529) 2023-08-11 15:46:41 +08:00
remote_browser.js Feature: remote browser support (#3904) 2023-12-01 15:29:10 +08:00
status_page.js Merge branch 'master' into feature/umami-analytics-status-page 2026-01-03 16:57:11 +01:00
tag.js Added JSDoc to ESLint (#3529) 2023-08-11 15:46:41 +08:00
user.js [Eliminate Blocking] User related (#5928) 2025-06-19 14:29:43 +08:00