spaziwk has asked for the wisdom of the Perl Monks concerning the following question:
I am useing Activestate Perl Service module (PerlSvc from thier Developers kit) to make it into a service. The servce runs fine but the service will not stop normamly. You have to manualy kill the process PID.
Active State Tech Support said: "It looks then like NextEvent is blocking in such a way that it doesn't respond to the service control commands, at least with your implementation."
The service stops OK if I use the NT Resource kit SRVANY, but I'd rather not use SRVANY because it is a seperate process and not as reliable as a perl based soloution.
I'd would appreciate any ideas to get this working or alternate methods that do not use the Active State perlsvc. Following is sample test code.
package PerlSvc; our %Config = (ServiceName => "TestService"); require Getopt::Long; $PerlSvc::Verbose = 0; # Put PerlSvc into quiet mode sub Startup { Getopt::Long::GetOptions('interval=s' => \$interval); #main::Init(); while(ContinueRun()) { # $ main::testservice(); # } } sub Interactive { # this callback is invoked when your service is not running as # a service and has been called without any of the --help, # --install or --remove options. Install(); Startup(); } sub Pause { # your service is about to be suspended } sub Continue { # your service will resume execution now } sub Install { Getopt::Long::GetOptions( 'interval=s' => \$interval, ); $Config{ServiceName} = "TestService"; $Config{DisplayName} = "TestService"; $Config{Description} = "TestService"; # add your additional install messages or functions here } sub Remove { # add your additional remove messages or functions here } sub Help { # add your additional help messages or functions here } package main; sub testservice { ################################################ Begin Program # +################################################# use Win32::OLE qw(in); my $evtQuery = "SELECT * FROM __instancecreationevent WHERE targetinst +ance ISA 'Win32_NTLogEvent' and (targetInstance.EventIdentifier= '592 +')"; my $Events = Win32::OLE->GetObject("WinMgmts:{impersonationLevel=imper +sonate,(security)}")-> ExecNotificationQuery($evtQuery) || warn + Win32::OLE->LastError; while (my $Event = $Events->NextEvent) { open (LOG, ">>testservice.log") || die "Could not Open testservice +.log"; print LOG ((localtime)." A new Process has been created\n"); close (LOG); return unless PerlSvc::ContinueRun(); } ############################################### END Program ##### +############################################### }
janitored by ybiC: Minor layout tweaks including balanced <readmore> tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem Stopping Service using Active State Perlsvc
by gellyfish (Monsignor) on Jun 23, 2005 at 14:16 UTC | |
|
Re: Problem Stopping Service using Active State Perlsvc
by Jenda (Abbot) on Jun 23, 2005 at 22:17 UTC |