Skip to content

Add optional email notifications for daily service restarts#34

Merged
svtica merged 4 commits intomainfrom
claude/fix-duplicate-restart-emails-w6b6W
Mar 19, 2026
Merged

Add optional email notifications for daily service restarts#34
svtica merged 4 commits intomainfrom
claude/fix-duplicate-restart-emails-w6b6W

Conversation

@svtica
Copy link
Copy Markdown
Owner

@svtica svtica commented Mar 19, 2026

Summary

This PR adds the ability to toggle email notifications when the daily service restart occurs, and improves the persistence of restart state to prevent duplicate restarts after service recovery.

Key Changes

  • New Setting: Added DailyRestartNotificationEnabled configuration option (defaults to True) to allow users to disable email notifications on daily restarts
  • UI Enhancement: Added checkbox in Options Form under the Monitoring tab to control daily restart notifications
  • Restart State Persistence: Implemented SaveLastDailyRestartDate() method to persist the last restart date to XML, preventing re-triggering of restarts when the service restarts within the same day window
  • Conditional Notifications: Modified daily restart logic to only send email notifications when the setting is enabled
  • Settings Management: Updated XMLManager to read/write the new notification setting and last restart date
  • Localization: Added French translations for the new daily restart UI elements and tooltips
  • Settings Reload: Added automatic reload of memory monitor settings in ApplicationContext when settings are saved

Implementation Details

  • The notification checkbox is automatically enabled/disabled based on the daily restart checkbox state
  • The last restart date is persisted before initiating the restart, ensuring a fresh service instance won't re-trigger within the same window
  • Default behavior maintains backward compatibility with notifications enabled by default
  • Proper error handling for persistence failures with appropriate logging

claude added 4 commits March 19, 2026 13:52
The daily restart feature was sending 6 emails because _lastDailyRestartDate
was only held in memory. When the service restarted, the field reset to
DateTime.MinValue, causing re-triggers within the 2-minute window.

Fix: persist the last restart date to XML before initiating the restart,
and load it on startup so the new service instance skips the same day.

Also adds a "Send Email Notification on Restart" checkbox in the Monitoring
tab (enabled by default) so users can disable restart notifications.

https://claude.ai/code/session_01FrpJXNzzfYiEA7UXqTMKZf
…aults

- Add 7 missing French translation entries in fr.xml for the daily restart
  checkbox, time label, notification checkbox, and their tooltips
- Add monitoring default values to SetDefaultValues() fallback method

https://claude.ai/code/session_01FrpJXNzzfYiEA7UXqTMKZf
ApplicationContext.LoadSettings() reloaded log and email settings but
never told the scheduler to pick up changed monitoring settings. This
meant daily restart time, notification toggle, etc. stayed stale until
the next app restart.

https://claude.ai/code/session_01FrpJXNzzfYiEA7UXqTMKZf
InitiateServiceRestart() always logged "[MemoryMonitor] Initiating
automatic service restart due to critical memory usage" even when called
from the daily restart path, making it look like two separate triggers
were firing. Now accepts a reason string so logs clearly distinguish
between "scheduled daily restart" and "critical memory usage".

Also renamed log prefix from [MemoryMonitor] to [ServiceRestart] since
the method is shared across callers.

https://claude.ai/code/session_01FrpJXNzzfYiEA7UXqTMKZf
@svtica svtica merged commit 7d7ff72 into main Mar 19, 2026
1 check passed
@svtica svtica deleted the claude/fix-duplicate-restart-emails-w6b6W branch March 19, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants