Re: [fpc-pascal] Best practice porting a Windows service application to Linux?

2020-04-22 Thread Michael Van Canneyt



On Thu, 23 Apr 2020, Bo Berglund via fpc-pascal wrote:


On Wed, 22 Apr 2020 07:56:38 +0200, Sven Barth via fpc-pascal
 wrote:


Bo Berglund via fpc-pascal  schrieb am
Mi., 22. Apr. 2020, 05:33:


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?



The service framework is available as TDaemonApplication in daemonapp.pp
and is available for both Windows and *nix systems. :)


It seems not to be available as an alternative in Lazarus new project
dialogue...
At least not in the Tool/Delphi conversion dialogue.


You must install the lazdaemon package, then it becomes available.

The conversion dialogue does not handle service applications specially, as
far as I know.

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


Re: [fpc-pascal] Best practice porting a Windows service application to Linux?

2020-04-22 Thread Bo Berglund via fpc-pascal
On Wed, 22 Apr 2020 07:56:38 +0200, Sven Barth via fpc-pascal
 wrote:

>Bo Berglund via fpc-pascal  schrieb am
>Mi., 22. Apr. 2020, 05:33:
>
>> 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?
>>
>
>The service framework is available as TDaemonApplication in daemonapp.pp
>and is available for both Windows and *nix systems. :)
>
It seems not to be available as an alternative in Lazarus new project
dialogue...
At least not in the Tool/Delphi conversion dialogue.


-- 
Bo Berglund
Developer in Sweden

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


Re: [fpc-pascal] Best practice porting a Windows service application to Linux?

2020-04-21 Thread Sven Barth via fpc-pascal
Bo Berglund via fpc-pascal  schrieb am
Mi., 22. Apr. 2020, 05:33:

> 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?
>

The service framework is available as TDaemonApplication in daemonapp.pp
and is available for both Windows and *nix systems. :)

Regards,
Sven

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


Re: [fpc-pascal] Best practice porting a Windows service application to Linux?

2020-04-21 Thread Dimitrios Chr. Ioannidis via fpc-pascal

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

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