punkish has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|