V
vkinger
Hi,
I have a problem where I am creating multiple parallel child processes
to connect to multiple servers. Each child process has a different
filehandle to read starttime from a text file at the time of fork and
then write into this text file each time it runs. Each child process
has a forever loop so that it never exits unless killed or reboot
occured at server and then it tries to reconnect. My problem is it
works for couple of times and logs data from different servers into
syslog but on 2nd or 3rd attempt(after being stopped by kill -9
<process id>) it only works with the one server( it can be 1st or 2nd
or 3rd as I am testing with only three servers at present) I am not
sure what is wrong, may be I can use some help here from the experts.
Here is what I am doing.
sub fork_pids
{
my @pids;
my $i = 0;
my $length = scalar(@lines);
my $pm = new Parallel::ForkManager($length);
print " Connecting to " , $length , " servers\n ";
for $i ( 1 .. $length )
{
print "spawning child processes $i\n";
$pm->start and next; #do the fork
print "Inside the child process\n";
&GetEventData($i-1);
$pm->finish;
}
$pm->wait_all_children;
}
Here I am checking the length that how many servers are configured in
the config.txt file and GetEventData is my function that takes index
into the number of server and calls the forever loop function. Same
index is used to create another text file inside this function to
record the timestamp associated with the data. Each server here
essentially does the same thing and logs into the syslog. It works
once or twice and then works with only one server.
I have a problem where I am creating multiple parallel child processes
to connect to multiple servers. Each child process has a different
filehandle to read starttime from a text file at the time of fork and
then write into this text file each time it runs. Each child process
has a forever loop so that it never exits unless killed or reboot
occured at server and then it tries to reconnect. My problem is it
works for couple of times and logs data from different servers into
syslog but on 2nd or 3rd attempt(after being stopped by kill -9
<process id>) it only works with the one server( it can be 1st or 2nd
or 3rd as I am testing with only three servers at present) I am not
sure what is wrong, may be I can use some help here from the experts.
Here is what I am doing.
sub fork_pids
{
my @pids;
my $i = 0;
my $length = scalar(@lines);
my $pm = new Parallel::ForkManager($length);
print " Connecting to " , $length , " servers\n ";
for $i ( 1 .. $length )
{
print "spawning child processes $i\n";
$pm->start and next; #do the fork
print "Inside the child process\n";
&GetEventData($i-1);
$pm->finish;
}
$pm->wait_all_children;
}
Here I am checking the length that how many servers are configured in
the config.txt file and GetEventData is my function that takes index
into the number of server and calls the forever loop function. Same
index is used to create another text file inside this function to
record the timestamp associated with the data. Each server here
essentially does the same thing and logs into the syslog. It works
once or twice and then works with only one server.