I'm no services expert, so I apologize ahead of time if I missed any service idiosyncrasies, but I hacked a service script together that works at a basic level. Below is the code I have that will properly start and stop w/ no errors. It doesn't include all the pausing, restarting, etc functionality, but it should provide a foundation to build on. All the code is taken from the examples section of the Roth's Consulting site ( http://www.roth.net/perl/Daemon/ ) I stripped it down alot and changed what I felt were typos. If nothing else, this should help to get you started.
use Win32::Daemon; $SERVICE_SLEEP_TIME = 20; Win32::Daemon::StartService(); sleep (1) while(SERVICE_START_PENDING != Win32::Daemon::State()); Win32::Daemon::State(SERVICE_RUNNING); $dontStop = 1; $count=0; # Note: the $count stuff is here in case i can't stop it.. purely for +debugging while (($dontStop) && ($count++ < 600)) { # Process stuff here open(OUT,">>e:\\temp3\\testout.txt"); print OUT localtime(); print OUT " $_\n" for (1..10); close(OUT); if(SERVICE_CONTROL_NONE != ($Message = Win32::Daemon::QueryLastMes +sage())) { if(SERVICE_CONTROL_INTERROGATE == $Message) { Win32::Daemon::State($PrevState); } elsif(SERVICE_CONTROL_STOP == $Message) { Win32::Daemon::State(SERVICE_STOP_PENDING, 25000); $dontStop = 0; } } Win32::Sleep($SERVICE_SLEEP_TIME); } Win32::Daemon::StopService();

In reply to Re: Issues with Win32::Daemon by jbware
in thread Issues with Win32::Daemon by Grygonos

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.