Having done a handful of successful services using Win32Daemon, I will give what help I can. The Windows Service Manager is a bit - picky - about how you talk to it, and how fast you respond. As you didn't provide very much of a code sample, I am going to show you the skeleton startup section that I use in every service script I have made to date - and hope that it will provide at least some assistance. You are welcome to /msg me on chatterbox if you like, as well.
#/perl/bin/perl use Win32; use Win32::Daemon; # Specify the amount of time to sleep between # polling the SCM for state changes. # This value is in milliseconds... $SERVICE_SLEEP_TIME = 100; # Start the service by connecting with the SCM and # doing what must be done to be a running service... Win32::Daemon::StartService() || die; $PrevState = SERVICE_START_PENDING; while( SERVICE_STOPPED != ( $State = Win32::Daemon::State() ) ) { if( SERVICE_START_PENDING == $State ) { # Initialization code Win32::Daemon::State( SERVICE_RUNNING ); $PrevState = SERVICE_RUNNING; } elsif( SERVICE_STOP_PENDING == $State ) { Win32::Daemon::State( SERVICE_STOPPED ); } elsif( SERVICE_PAUSE_PENDING == $State ) { # "Pausing..." Win32::Daemon::State( SERVICE_PAUSED ); $PrevState = SERVICE_PAUSED; next; } elsif( SERVICE_CONTINUE_PENDING == $State ) { # "Resuming..." Win32::Daemon::State( SERVICE_RUNNING ); $PrevState = SERVICE_RUNNING; next; } elsif( SERVICE_STOP_PENDING == $State ) { # "Stopping..." Win32::Daemon::State( SERVICE_STOPPED ); $PrevState = SERVICE_STOPPED; next; } elsif( SERVICE_RUNNING == $State ) { # The service is running as normal... # ...add the main code here... #NOTE: This should be code that iterates and #stops,so sleep / wake #can be controlled by the services skeleton. # Check for any outstanding commands. Pass in a #non zero value # and it resets the Last Message to #SERVICE_CONTROL_NONE. if( SERVICE_CONTROL_NONE != ( my $Message = Win32::Daemon::QueryLastMessage( 1 ) ) ) { if( SERVICE_CONTROL_INTERROGATE == $Message ) { # Got here if the Service Control Manager is #requesting # the current state of the service. #This can happen for # a variety of reasons. Report the last state #we set. Win32::Daemon::State( $PrevState ); } elsif( SERVICE_CONTROL_SHUTDOWN == $Message ) { # Yikes! The system is shutting down. #We had better clean up and stop. # Tell the SCM that we are preparing to shutdown # and that we expectit to take 25 seconds # (so don't terminate us for at least 25 # seconds)... Win32::Daemon::State( SERVICE_STOP_PENDING, 25000 ); } else { # Got an unhandled control message. # Set the state to # whatever the previous state was. Win32::Daemon::State( $PrevState ); } } } # Snooze for awhile so we don't suck up cpu time... Win32::Sleep( $SERVICE_SLEEP_TIME ); } # We are done so close down... Win32::Daemon::StopService();
Incidently, since I started using this skeleton, I have never had a problem starting a service script, so it might be worth a shot for you.
Mike Gucciard

In reply to Re: Issues with Win32::Daemon by gooch
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.