3

I have a Windows Service, for which I set up recovery options when the service fails (via the Services App, in the Recovery Tab of the Service Properties).

The options currently are set so that there is a first and second try to restart after 15 Minutes, then reset the fail counter after a day. The startup type is automatic with delay.

While this usually works, I does not seem to make any retries after a failed start after a reboot. The following is an excerpt from the Windows Event Log:

11.06.2020 02:18:28 The process C:\WINDOWS\system32\svchost.exe (S701028A) has initiated the restart of computer S701028A on behalf of user NT AUTHORITY\SYSTEM for the following reason: Operating System: Recovery (Planned) Reason Code: 0x80020002  Shutdown Type: restart  Comment:  
11.06.2020 02:20:11 The XYZ Service service entered the stopped state.
11.06.2020 02:20:16 The operating system is shutting down at system time ‎2020‎-‎06‎-‎11T00:20:16.361111600Z.
....
11.06.2020 02:20:19 The operating system started at system time ‎2020‎-‎06‎-‎11T00:20:19.490015600Z.
11.06.2020 02:24:10 The XYZ service failed to start due to the following error: The service did not respond to the start or control request in a timely fashion.
11.06.2020 02:24:10 A timeout was reached (30000 milliseconds) while waiting for the XYZ service to connect.

It seems that the recovery options do only apply for process exits, not for system boots. How can I define retries after system boot?

Notes: OS Name Microsoft Windows Server 2012 R2 Standard Version 6.3.9600 Build 9600

1
  • If it's just for this computer, I would imagine setting the servicepipetimeout to 90 seconds might be the easiest thing to do if you just want to make it more reliable. Commented Jun 24, 2020 at 14:57

1 Answer 1

4

A service's failure actions are only invoked at a defined point in a service's life cycle. From the documentation on service failure actions:

A service is considered failed when it terminates without reporting a status of SERVICE_STOPPED to the service controller.

Implicit in that statement is that a service must have been in the SERVICE_RUNNING state prior to its unexpected exit. That is, failure actions are not invoked for a service that doesn't make it to SERVICE_RUNNING.

In your specific example, the XYZ service failed to start (i.e. it never transitioned to SERVICE_RUNNING) so no failure actions are called.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .