I am stumped with a non-responsive Win32::Daemon service on my hands. (background: I am using ActiveState Perl 5.8.4 on a WinXP box).

First, I created a complicated perl script as a Win32 service. The service installs perfectly, but fails to start with "Error 1053: Could not start the ComplicatedTask on Local Computer". The Event Viewer says "Timeout (30000 milliseconds) waiting for the ComplicatedTask service to connect."

Then I pared down my script to a really simple perl script. Just a simple

print LOG "hello\n";

No cigar. Still the same errors as above.

I have read the node Win32::Daemon and put the little

BEGIN { open( STDERR, ">>D:/htdocs/myservicelog.err" ) or die "invisible err +or"; warn "$0 started ".localtime().$/; }

as prescribed by tye. The log gets a dutiful

complicatedtask.pl started Mon Dec 27 14:38:24 2004 etc.

My code is in a standard Win32::Daemon service control loop as in

open LOG, ">>mylogfile.txt" or die; # Start the service control loop Win32::Daemon::StartService(); while( SERVICE_STOPPED != ( $State = Win32::Daemon::State() ) ){ if( SERVICE_STARTING == $State ) { # some service startup code ...... Win32::Daemon::State( SERVICE_RUNNING ); } elsif( SERVICE_PAUSE_PENDING == $State ) { Win32::Daemon::State( SERVICE_PAUSED ); next; } elsif( SERVICE_CONTINUE_PENDING == $State ) { Win32::Daemon::State( SERVICE_RUNNING ); next; } elsif( SERVICE_STOP_PENDING == $State ) { # some service shutdown code ............ Win32::Daemon::State( SERVICE_STOPPED ); next; } elsif( SERVICE_CONTROL_SHUTDOWN == $State ) { # Request x seconds to shutdown... Win32::Daemon::State( SERVICE_STOP_PENDING, 45 ); .............. Win32::Daemon::State( SERVICE_STOPPED ); next; } elsif( SERVICE_RUNNING == $State ) { doMyStuff(); sleep 30; } else { # Un-handled control messages Win32::Daemon::State( SERVICE_RUNNING ); } sleep 5; } Win32::Daemon::StopService(); sub doMyStuff { print LOG "hello\n"; }

What now? Is there any other error log that I can turn on that actually reports on _why_ the service didn't respond in a timely fashion?

Btw, the task script works fine when not installed as a service.


In reply to Win32::Daemon installed service fails to start by punkish

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.