seaver has asked for the wisdom of the Perl Monks concerning the following question:
Me again...
I'm using a SOAP::Lite XMLRPC daemon to accept requests from an applet. So far it works very well, even when accepting multiple requests
However, it has developed an annoying habit recently of actually EXITING once it's finished all requests...which is weird...any help would be appreciated
thanks
Sam
#!/usr/bin/env perl use XMLRPC::Transport::HTTP; use XML::Xerces; use XML::Xerces::DOMParse; use Carp; use Fcntl ":flock"; my $daemon = XMLRPC::Transport::HTTP::Daemon -> new (LocalPort => 8081, Reuse => 1) -> dispatch_to('Monster') ; print "Contact to XMLRPC server at ", $daemon->url, "\n"; $daemon->handle; package Monster; sub go{ shift if UNIVERSAL::isa($_[0] => __PACKAGE__); my $CP = shift; my $filePath = "/usr/local/jakarta-tomcat-4.1.12/webapps/monster/j +obs/"; $|=1; my $parser = XML::Xerces::DOMParser->new(); $parser->setCreateEntityReferenceNodes(1); my $error_handler = XML::Xerces::PerlErrorHandler->new(); $parser->setErrorHandler($error_handler); my $in; eval {$in = XML::Xerces::MemBufInputSource->new($CP);}; error($@) if $@; eval {$parser->parse($in);}; error($@) if $@; my $doc = $parser->getDocument(); my $cps = $doc->getElementsByTagName("ChainPairs"); my $id = $cps->item(0)->getAttributes()->getNamedItem("index")->ge +tNodeValue(); my $filePath2 = "$filePath$id/"; mkdir $filePath2; my $fileNode = $doc->getElementsByTagName("File"); my $file = $fileNode->item(0)->getChildNodes->item(0)->getNodeValu +e(); $file = substr($file, 37); $pdb = substr($file, 0, -4); open (F, ">$filePath2$pdb.cp" ) or die "couldn't open file $pdb.cp +: $!"; flock(F, LOCK_EX); print F $CP; flock(F, LOCK_UN); close F; use POSIX ":sys_wait_h"; sub REAPER{ my $child; while (($child = waitpid(-1,&WNOHANG)) > 0) { $Kid_Status{$child} = $?; } $SIG{CHLD} = \&REAPER; # still loathe sysV } $SIG{CHLD} = \&REAPER; exec("/usr/local/bin/monster", "-i$id", "$filePath$file") unless fork( +); return 0; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Daemon exits!
by sgifford (Prior) on Jun 19, 2003 at 01:23 UTC | |
by seaver (Pilgrim) on Jun 19, 2003 at 15:34 UTC | |
|
Re: Daemon exits!
by tall_man (Parson) on Jun 19, 2003 at 15:27 UTC |