Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

restart service in case of exception

I'm developing service application that must restart itself. What are the ways of doing that? Is it possible to ask system start application again if it is stopped? I'm using Delphi 2007.

like image 384
vico Avatar asked Dec 05 '22 15:12

vico


2 Answers

Your service can programably configure recovery options for itself by calling the Win32 API ChangeServiceConfig2() function inside of its AfterInstall event. Set the dwInfoLevel to SERVICE_CONFIG_FAILURE_ACTIONS and set the lpInfo to point at a SERVICE_FAILURE_ACTIONS record describing what you want to happen when the service fails.

like image 154
Remy Lebeau Avatar answered Dec 27 '22 23:12

Remy Lebeau


If you go into services.msc you can configure this for you service. You don't have to do it in code. See the Recovery tab when you open the properties of you service.

like image 29
Gerald Versluis Avatar answered Dec 27 '22 23:12

Gerald Versluis