Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Reason of Service Termination

Tags:

service

delphi

I use a service application I created in Delphi. My problem is that it is sometimes terminated by the operating system and I don't know why this happens.

When I go the the system events, I can find a piece of information like this one:

Event ID: 7034, The [...] service terminated unexpectedly. It has done this [...] time(s).

I know you can't give me an answer why this happens, but could you please give me a clue what to pay attention to to find the reason of that behaviour? For instance what kind of exceptions could make the OS close an application.

Thank you in advance.

like image 830
Mariusz Schimke Avatar asked Dec 22 '22 04:12

Mariusz Schimke


2 Answers

Make a debug version with Eurekalog or MadExcept, and it'll tell you where it's blowing up, what the stack looked like, memory, etc..

They can also auto-restart your app. Not sure if that can be done on a service, but for regular apps, it can. They can also send you the dump via e-mail, or even post directly to a bug tracker like FogBugz or Mantis. These measures will be helpful in the event that you don't find a smoking gun right away, and need to keep troubleshooting/debugging in place as a long-term solution. i.e. even if something only crashes once a month or even once a year, it's easier to tell your boss "I'm looking at the logs" than "I really have no idea".

like image 155
Chris Thornton Avatar answered Dec 27 '22 20:12

Chris Thornton


Make sure you are capturing all exceptions within the Execute method of all your threads Assuming your are using TThread descendants). If any get through to the OS this might cause it to terminate your service.

like image 39
dummzeuch Avatar answered Dec 27 '22 20:12

dummzeuch