Recent

Author Topic: Any ideas on how to debug service/daemon (using Lazdaemon)  (Read 13329 times)

jl

  • Full Member
  • ***
  • Posts: 178
Any ideas on how to debug service/daemon (using Lazdaemon)
« on: July 10, 2009, 05:55:05 pm »
I've been playing around with Lazdaemon for the past few days and found it to be quite a challenge and not plug as play as its delphi counterpart is.  If i am going to make the same code work for both linux and windows, even more work is required, especially for embedded linux.

Ironically debugging a daemon in linux is actually easier since you can capture the output to terminal directly.

I am looking for recommended practices for debugging Lazdaemon services on Windows platform, hope any of you with can share your experience for both Linux and Windows.  There's very little info on Lazdaemon in the forums or Internet, so your contribute will add to the knowledge base.  Thanks.   :D

Loesje

  • Full Member
  • ***
  • Posts: 168
    • Lazarus Support website
Re: Any ideas on how to debug service/daemon (using Lazdaemon)
« Reply #1 on: July 11, 2009, 11:33:39 am »
What I do is debugging with linux, and then it works on windows. I have thought to add a debuggable-mode for windows. (That is: just execute the code without using the windows-service-listeners) but that was not necessary because I could use Linux for debugging.

The only thing you can't debug is the service-related part, but that should 'just work'. Only keep in mind that a service works with other rights and in a nother default directory.

When you really need to debug using windows, just add 'application.logger.warning('something');' (could be a little bit different, but this is the idea) and check your application-log.

jl

  • Full Member
  • ***
  • Posts: 178
Re: Any ideas on how to debug service/daemon (using Lazdaemon)
« Reply #2 on: July 13, 2009, 07:05:31 am »
What I do is debugging with linux, and then it works on windows. I have thought to add a debuggable-mode for windows. (That is: just execute the code without using the windows-service-listeners) but that was not necessary because I could use Linux for debugging.

Thanks for the ideas.  I tried that, it works most of the time, except for some errors that appear only in windows, for example, i discovered that debugln among others will hang the service in Windows but works ok in Linux.

I'm trying to achieve what a debugger can do at real time for GUI apps - to pinpoint the exact lines of code where the problem occurs.  I'm now exploring DumpExceptionBackTrace.
« Last Edit: July 13, 2009, 07:17:38 am by touchring »

Loesje

  • Full Member
  • ***
  • Posts: 168
    • Lazarus Support website
Re: Any ideas on how to debug service/daemon (using Lazdaemon)
« Reply #3 on: July 14, 2009, 10:10:19 pm »
Thanks for the ideas.  I tried that, it works most of the time, except for some errors that appear only in windows, for example, i discovered that debugln among others will hang the service in Windows but works ok in Linux.

That's not true. It also doesn't work in linux. It will lock your terminal, when you close your terminal-session, you'll see that the daemon is also killed. Because the daemon holds a lock on stdout...

It can be used to debug, though...

jl

  • Full Member
  • ***
  • Posts: 178
Re: Any ideas on how to debug service/daemon (using Lazdaemon)
« Reply #4 on: July 15, 2009, 10:33:36 am »
Thanks for the ideas.  I tried that, it works most of the time, except for some errors that appear only in windows, for example, i discovered that debugln among others will hang the service in Windows but works ok in Linux.

That's not true. It also doesn't work in linux. It will lock your terminal, when you close your terminal-session, you'll see that the daemon is also killed. Because the daemon holds a lock on stdout...

It can be used to debug, though...


Thanks.  I tried to run it using Alt-F2, 'run application' box, it works regardless of whether or not I am using Writeln.  Conversely, the daemon terminates when I close my terminal-session (if I launch it from the terminal), regardless of whether or not I am using Writeln.

But just in case, I added another check:

if paramstr(2)='-d' then writeln(message)

 

TinyPortal © 2005-2018