----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, November 29, 2000 2:29 PM
Subject: perl as a service


> I'm using win32::daemon to run my script as a service, and it works great.
> Whenever I encounter an unknown state of the service, I'm resetting it
back
> to the previous state, just like Dave Roth says in his doc.  That works
> fine, too. My problem is that if I leave the script run for a while, the
> event log is filling up with 'service returned an invalid state' messages.
>
> Does anyone have any suggestions for how to work around this, or prevent
> these messages from going to the event log?
> Using ActiveState Build 618 + Win2k.

I haven't run across an invalid state on either NT4.0 or W2K.  I have my
scripts stopping the service for that condition.  You could build a counter
with a loop breaking on a certain number of cycles.

Something like - (totally untest and just off the top of my head)

%goodstates = ('1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6,
'7' => 7);
sub control
{
sleep(1);
$state = Win32::Daemon::State();
if($state == 1){Win32::Daemon::StopService(); exit 1;}
elsif($state == 2){Win32::Daemon::State(SERVICE_RUNNING);&control;}
elsif($state == 3){Win32::Daemon::State(SERVICE_STOPPED);&control;}
elsif($state == 4){return()}
elsif($state == 5){Win32::Daemon::State(SERVICE_RUNNING);&control;}
elsif($state == 6){Win32::Daemon::State(SERVICE_PAUSED);&control;}
elsif($state == 7){&control;}
else
    {
     while (($c3 < 20 ) && (!$goodstates{$state})
        {
        $c3++;
        sleep(1);
        $state = Win32::Daemon::State();
        }
    print "I'm tired of this unknow state and I'm leaving\n";
    Win32::Daemon::StopService();
    exit 1;}
    }
  }






_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to