I have two suggestions.

  1. Whilst developing your server, run it as a normal console application.

    The thing to remember is that everything inside the SERVICE_RUNNING branch of the top level if/then/elsif/else cascade (which is better replaced by a dispatch table!), is just "normal" code, except that it usually doesn't have access to a console.

    If you put your main logic within a subroutine and call it from that branch of the cascade (or dispatch to it), and you put that sub into a separate module, then writing a test harness that just loads that module and invokes the sub is trivial. You also get access to a console and can use what ever debug techniques (from print on up) that you would normally use to get your logic right.

    Once you are satisfied with your logic running as a console app, moving back to running it as a Service is easy. It will also highlight any problems that arise as a result of running as a service.

  2. If you find that when you make your tested app a service you still need to debug something that only shows up in the Service.

    Get yourself to http://www.smidgeonsoft.com/, and download PEBrowse Professional Interactive. And be sure to read the tutorial. There is a link to it at the bottom of that page.

    It will allow you to attach to the running Service, set break points, disassemble the code and supports using symbol files if you tell it where to look.

    Be warned. It operates at the assembler level, not the Perl source level, which takes some getting used to, but if you have thoroughly debugged your code before making it a Service, there are a limited number of thing s you will need to look at, and they are fairly simple to decipher at the assembler level.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Debugging Windows Services created with Win32::Daemon by BrowserUk
in thread Debugging Windows Services created with Win32::Daemon by hackdaddy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.