i created a service manager application that allows to install (with SC CREATE), start (using a code very similar to the one in the answer to:How to start a windows service in Delphi for Windows 8), stop and uninstall a service.
The service is a windows server exe app written in Delphi.
Suddenly (a few days ago) i was not able to start the service anymore on a specific machine (a Windows Server 2012R2), this occurs both from my application than from windows service console.
The same exes (manager and service) work fine on other machines (in particular another Windows Server 2012R2 and my windows 10 workstation) .
This is what i "measured":
1) when i try to start the service this code StartService(schs,0,psTemp)
(WinAPI call - refer to link above) does not return true;
2) if i put OutpuDebugString
messages in the dpr i cannot see them in DebugView, meaning that the service exe is not started
3) in the windows System event logger i see that there is a 30 seconds timeout while tryin to connect to the service
4) even if i create a dummyservice.exe that does nothing but writing some OutpuDebugString
i am not able to start it
This is the implementation of the dummy service:
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
Dummy.Controller(CtrlCode);
end;
function TDummy.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TDummy.ServiceAfterInstall(Sender: TService);
begin
OutputDebugString('ServiceAfterInstall');
end;
procedure TDummy.ServiceAfterUninstall(Sender: TService);
begin
OutputDebugString('ServiceAfterUninstall');
end;
procedure TDummy.ServiceBeforeInstall(Sender: TService);
begin
OutputDebugString('ServiceBeforeInstall');
end;
procedure TDummy.ServiceBeforeUninstall(Sender: TService);
begin
OutputDebugString('ServiceBeforeUninstall');
end;
procedure TDummy.ServiceExecute(Sender: TService);
var
cnt : Integer;
begin
cnt :=0;
while not Terminated do
begin
inc(CNT);
OutputDebugString(Pwidechar('ServiceExecute Count '+IntTOstr(Cnt)));
Sleep(1000);
ServiceThread.ProcessRequests(False);
end;
end;
procedure TDummy.ServiceStart(Sender: TService; var Started: Boolean);
begin
OutputDebugString('ServiceStart');
end;
procedure TDummy.ServiceStop(Sender: TService; var Stopped: Boolean);
begin
OutputDebugString('ServiceStop');
end;
On this specific machine two weeks ago i was able to start the service, nothing particular has been done.
I wonder what i can do to debug more, i am stuck.
Why there is a timeout, it seems my service exe is not even started (if it were i guess I would see the OutputDebugString
messages in DebugView)?
This happens on one machine only, on one machine that up to a few days ago was performing normally.
Thanks to anyone who can help!