From dd550a4635ea8ceb63eb4433946ec3af5bf7c852 Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Tue, 15 Mar 2011 11:00:36 +0000 Subject: helper process that rather dumbly starts gnunet peers --- contrib/peerStartHelper.pl | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 contrib/peerStartHelper.pl diff --git a/contrib/peerStartHelper.pl b/contrib/peerStartHelper.pl new file mode 100755 index 000000000..c3994c32b --- /dev/null +++ b/contrib/peerStartHelper.pl @@ -0,0 +1,62 @@ +#!/usr/bin/perl +use strict; + +my $max_outstanding = 300; + +$ARGV[0] || die "No directory provided for peer information, exiting!\n"; + +my $directory = $ARGV[0]; +my @config_files = `find $directory -iname gnunet-testing-config*`; +my @child_arr = {}; +my $count = 0; +my $outstanding = 0; +foreach my $file (@config_files) +{ + chomp($file); + #print "Starting GNUnet peer with config file $file\n"; + my $pid = fork(); + if ($pid == -1) + { + die; + } + elsif ($pid == 0) + { + exec "gnunet-arm -q -c $file -s" or die; + } + + if ($pid != 0) + { + push @child_arr, $pid; + $count++; + $outstanding++; + if ($outstanding > $max_outstanding) + { + for (my $i = 0; $i < $max_outstanding / 5; $i++) + { + #print "Too many outstanding peers, waiting!\n"; + waitpid($child_arr[0], 0); + shift(@child_arr); + $outstanding--; + } + } + } +} + +print "All $count peers started (waiting for them to finish!\n"; + +while ($outstanding > 0) +{ + waitpid($child_arr[0], 0); + shift(@child_arr); + $outstanding--; + if ($outstanding % 50 == 0) + { + print "All $count peers started (waiting for $outstanding to finish!\n"; + } +} + +while (wait() != -1) {sleep 1} + +print "All $count peers started!\n"; + + -- cgit v1.2.3