views:

773

answers:

3

I configure the recovery for Windows services to restart with a one minute delay after failures. But I have never gotten it to actually restart the service (even with the most blatant errors).

I do get a message in the EventViewer:

The description for Event ID ( 1 ) in Source ( MyApp.exe ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: Access violation at address 00429874 in module 'MyApp.exe'. Write of address 00456704.

Is there something else I have to do? Is there something in my code (I use Delphi) which needs to be set to enable this?

+3  A: 

Service Recovery is intended to handle the case where a service crashes - so if you go to taskmgr and right click "end process" on your service process, the recovery logic should kick in. I don't believe that the service recovery logic kicks in if your service exits gracefully (even if it exits with an error).

Also the eventvwr message indicates that your application called the ReportEvent API specifying event ID 1. But you haven't registered your event messages with the event viewer so it can't convert event ID 1 into a meaningful text string.

Larry Osterman
Thanks. This shed some light on the situation. I found when I did a "End Process" from taskmgr it produces this in the event viewer:The following corrective action will be taken in 60000 milliseconds: Restart the service. Now my problem (which is related to my coding) is to have it terminiate "Un-Gracefully" so that the recovery logic will kick in.
M Schenkel
If you call ExitProcess that should be sufficient.
Larry Osterman
+1  A: 

Larry is right, if the service doesn't "crash" then the recovery won't kick in. Better to use a third party monitoring tool like Service Hawk, which can restart a service every once in a while regardless to keep it running cleanly and reliably.

ExtraLean
A: 

I have created a Window Service and facing the same issue.

In my Window Service if Service is enable to connect to SQL Server it throws an exception and windows service will not start. I have set recovery option of Windows Service to First Failure, Second Failure to Restart the Service, Reset fail count after 1 day and Restart Service to 0 minutes.

What I want is when service throws an exception service should go for recovery option which I have configured and should try to restart the service.

After configuring service for recovery option if I got to the Task Manager and manually end the process then only this recovery option gets applied.

Can anyone help me on this?

Ravi Khambhati
I ended up creating another service which simply monitors my services and restarts them (basically like a Service Hawk as ExtraLean alludes to). I am really perplexed too; the notion there is a difference between a "Crash" and a "Exit gracefully - with errors". I would have thought the only condition to NOT restart is a graceful exit WITHOUT ERRORS.
M Schenkel