Jump to content
thomh

Delphi service in a domain controlled environment

Recommended Posts

Hi, we have a bunch of customers running our Delphi coded RealThinClient server as a service in a domain controlled server environment.

 

They have set Windows Update to check for updates but not to automatically install them.

 

When the server does a Windows update check it happens often that our Delphi services stop responding.  If we stop the services we cannot start them again until we restart the server. Something happens in a domain controlled server environment when this Windows update check is done that messes up the services.

 

Our .Net services are not affected and keeps on running.

 

Has anybody seen or heard of this problem and is there a solution?

 

Thanks,

Thom

 

Share this post


Link to post

Hi David,

 

Delphi service that does nothing stops also. It might have something to do with how I start the service. This is straight from the RTC demo app. Is there a more "modern" way of starting the service?

 

function ServiceStart(const aMachine, aService: String) : Boolean;
var
  schm,
  schs: SC_Handle;
  ss: TServiceStatus;
  psTemp: PChar;
  dwChkP: DWord;
begin
  ss.dwCurrentState := 1;
  schm := OpenSCManager(PChar(aMachine), nil, SC_MANAGER_CONNECT);
  if (schm > 0) then
  begin
    schs := OpenService(schm, PChar(aService), SERVICE_START or SERVICE_QUERY_STATUS);
    if (schs > 0) then
    begin
      psTemp := nil;
      if (StartService(schs, 0, psTemp)) then
      begin
        if (QueryServiceStatus(schs, ss)) then
        begin
          while (SERVICE_RUNNING <> ss.dwCurrentState) do
          begin
            dwChkP := ss.dwCheckPoint;
            Sleep(ss.dwWaitHint);
            if (not QueryServiceStatus(schs, ss)) then
              Break;
            if (ss.dwCheckPoint < dwChkP) then
              Break;
          end;
        end;
      end;
      CloseServiceHandle(schs);
    end;
    CloseServiceHandle(schm);
  end;
  Result := SERVICE_RUNNING = ss.dwCurrentState;
end;
 

 

Share this post


Link to post

I think a standard Delphi service would be using TService.

http://docwiki.embarcadero.com/RADStudio/Sydney/en/Service_Applications

 

Just create a service project and put this in OnExecute event:

 procedure TService1.Service1Execute(Sender: TService);
 begin
   while not Terminated do 
     ServiceThread.ProcessRequests(True);
 end;

 

Edited by Cristian Peța

Share this post


Link to post

Our services runs on domain controlled servers and are descendents from TService, but they must be configured to run with a specific AD user (i.e. not the default system user) that has the necessary rights to access it's own file, and to start and stop services to be able to upgrade themselves. 

Share this post


Link to post

I would be rather surprised if this has anything to do with RTC itself.

However, building service code (or DI stuff) on demos can bite back.

I do know that some of the RTC demos are compatible back to... well very long.

So maybe you found a demo that was written with very long backwards compatibility in mind..

RTC do not make any presumptions on how you write your service DM.

I'd suggest you delve deep into TService and all that.

Also - this is a painful methodology, eps if the fault cannot be simulated in you dev environ - start to rip things out and see it it starts working.

 

HTH

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×