Hi,

Στις 22/4/2020 1:02 π.μ., ο Bo Berglund via fpc-pascal έγραψε:

< sip >
But what about the general service framework?
The existing code uses a class inherited from TService, does this
exist on FPC for Windows and Linux?
So it can be crosscompiled for both platforms?

Attached you'll find a skeleton project that I use for windows / linux services ( incuded an fclel.res file for windows event loggging ).

For debugging I use the usual technique. An infinity loop in debug mode :

    Run Lazarus with administrator rights.

    Start the service which will hang into the loop.

    Add a breakpoint inside the loop and attach the service process.

    Evaluate, modify the boolean variable which used in the loop from true to false, and you're inside the service ....

#############################################

....

{$IFDEF DEBUG_BUILD}
  {$DEFINE DEBUG_BUILD_SERVICE}
{$ENDIF}

.....

  TFPSVC = class(TCustomDaemon)
  private
{$IFDEF DEBUG_BUILD_SERVICE}
    FServiceDebug: boolean;
{$ENDIF}

.....

  function TFPSVC.Start: boolean;
  begin
{$IFDEF DEBUG_BUILD_SERVICE}
    FServiceDebug := True;
    While FServiceDebug do      <------------------- add a breakpoint here
      Sleep(2000);
{$ENDIF}

......

#############################################

--

Dimitrios Chr. Ioannidis

<<attachment: fpc_service.zip>>

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to