[fpc-pascal] Best practice porting a Windows service application to Linux?
Dimitrios Chr. Ioannidis
d.ioannidis at nephelae.eu
Wed Apr 22 01:11:06 CEST 2020
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fpc_service.zip
Type: application/x-zip-compressed
Size: 2979 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20200422/67ea57eb/attachment.bin>
More information about the fpc-pascal
mailing list