MCPcopy
hub / github.com/cloudflare/cloudflared / configRecoveryOption

Function configRecoveryOption

cmd/cloudflared/windows_service.go:303–317  ·  view source on GitHub ↗

until https://github.com/golang/go/issues/23239 is release, we will need to configure through ChangeServiceConfig2

(handle windows.Handle)

Source from the content-addressed store, hash-verified

301// until https://github.com/golang/go/issues/23239 is release, we will need to
302// configure through ChangeServiceConfig2
303func configRecoveryOption(handle windows.Handle) error {
304 actions := []recoveryAction{
305 {recoveryType: uint32(scActionRestart), delay: uint32(recoverActionDelay / time.Millisecond)},
306 }
307 serviceRecoveryActions := serviceFailureActions{
308 resetPeriod: uint32(failureCountResetPeriod / time.Second),
309 actionCount: uint32(len(actions)),
310 actions: uintptr(unsafe.Pointer(&actions[0])),
311 }
312 if err := windows.ChangeServiceConfig2(handle, windows.SERVICE_CONFIG_FAILURE_ACTIONS, (*byte)(unsafe.Pointer(&serviceRecoveryActions))); err != nil {
313 return err
314 }
315 serviceFailureActionsFlag := serviceFailureActionsFlag{enableActionsForStopsWithErr: 1}
316 return windows.ChangeServiceConfig2(handle, serviceConfigFailureActionsFlag, (*byte)(unsafe.Pointer(&serviceFailureActionsFlag)))
317}

Callers 1

installWindowsServiceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected