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


In reply to Win32::Daemon problem by cruelty

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.