Skip to content

Commit

Permalink
PR review: move docs to docs/architecture, add clarifying comments, m…
Browse files Browse the repository at this point in the history
…ore readable const
  • Loading branch information
zackattack01 committed Jun 25, 2024
1 parent fd0cb69 commit 5060d05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
### Watchdog Service

Note that for the initial implementation, this service is windows only. It is intentionally designed to give room for alternate OS implementations if needed in the future.
Most of the relevant code can be found in [ee/watchdog](../../ee/watchdog/)

Here is a basic sequence diagram displaying the enable path for the windows watchdog service. The `launcher_watchdog_enabled` control flag will trigger the initial configuration and installation, and removal of the flag will trigger removal of the service.

```mermaid
Expand Down
8 changes: 5 additions & 3 deletions ee/watchdog/controller_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (

serviceDoesNotExistError string = "The specified service does not exist as an installed service."

serviceResetPeriod uint32 = 10800 // 3 hours in seconds
serviceResetPeriodSeconds uint32 = 3 * 60 * 60 // 3 hours in seconds
)

// WatchdogController is responsible for:
Expand Down Expand Up @@ -87,7 +87,9 @@ func (wc *WatchdogController) Run() error {
}

func (wc *WatchdogController) publishLogs(ctx context.Context) {
// do nothing if watchdog is not enabled
// note that there is a small window here where there could be pending logs before watchdog is disabled -
// there is no harm in leaving them and we could recover these with the original timestamps if we ever needed.
// to avoid endlessly re-processing empty logs while we are disabled, we accept this possibility and exit early here
if !wc.knapsack.LauncherWatchdogEnabled() {
return
}
Expand Down Expand Up @@ -264,7 +266,7 @@ func (wc *WatchdogController) installService(serviceManager *mgr.Mgr) error {
},
}

if err = restartService.SetRecoveryActions(recoveryActions, serviceResetPeriod); err != nil {
if err = restartService.SetRecoveryActions(recoveryActions, serviceResetPeriodSeconds); err != nil {
wc.slogger.Log(ctx, slog.LevelWarn,
"unable to set recovery actions for service installation, proceeding",
"err", err,
Expand Down

0 comments on commit 5060d05

Please sign in to comment.