cruelty has asked for the wisdom of the Perl Monks concerning the following question:
G'day,
I'm trying to set up a service on Windows NT using Dave Roths Win32::Daemon module. When I try to start it, after waiting for about 3 minutes, I'm getting the following message : "Service is not responding to the control function".
This seems to be caused by using self written modules. If I remove 'use testPackage', everything seems to run normal and the service gets started.
Did anyone already strugle with this problem before ?
Many thanks in advance,
Cruelty.
------------
package testPackage; sub new { my $that = shift; my $class = ref($that) || $that; my $self; $self->{DEBUG} = shift; bless $self, $class; return $self; } 1; ----------- use Win32::Daemon; use strict; use testPackage; my $LOGFILE = "test.log"; sub verbose { warn "TRACE ($$) : $_[0]"; } open (STDERR, ">$LOGFILE") || die "cannot open log file $LOGFILE\n"; Win32::Daemon::StartService(); my $prevState = SERVICE_STOPPED; while (SERVICE_STOPPED != ( my $State = Win32::Daemon::State() ) ) { if ( SERVICE_START_PENDING == $State ) { Win32::Daemon::State( SERVICE_RUNNING ); $prevState = SERVICE_RUNNING; verbose("$0 started at " . localtime().$/); } elsif ( SERVICE_PAUSE_PENDING == $State ) { verbose("Pausing Service\n"); Win32::Daemon::State( SERVICE_PAUSED ); $prevState = SERVICE_PAUSED; next; } elsif ( SERVICE_CONTINUE_PENDING == $State ) { verbose("Resuming Service\n"); Win32::Daemon::State( SERVICE_RUNNING ); $prevState = SERVICE_RUNNING; next; } elsif ( SERVICE_STOP_PENDING == $State ) { verbose("Service Stopping"); Win32::Daemon::State( SERVICE_STOPPED ); $prevState = SERVICE_STOPPED; next; } elsif ( SERVICE_RUNNING == $State ) { if ($DEBUG) { verbose("Service Running"); } if ( $DEBUG ) { verbose ("Waiting 100 seconds to continue\n"); } sleep(100); } else { # unknown state : reset to previous state Win32::Daemon::State( $prevState ); } sleep(1); } Win32::Daemon::StopService();
Edit kudra, 2001-09-17 Added code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::Daemon problem
by $code or die (Deacon) on Sep 17, 2001 at 22:44 UTC | |
by cruelty (Novice) on Sep 20, 2001 at 21:56 UTC | |
by $code or die (Deacon) on Sep 21, 2001 at 03:44 UTC |