summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-03-15 11:00:36 +0000
committerNathan S. Evans <evans@in.tum.de>2011-03-15 11:00:36 +0000
commitdd550a4635ea8ceb63eb4433946ec3af5bf7c852 (patch)
treee2e32715d56dea4deebf9be2eb9eea85c9b813a4 /contrib
parent7c25a6b3f331213491c8bcb1d84e8ea7d96e3cac (diff)
helper process that rather dumbly starts gnunet peers
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/peerStartHelper.pl62
1 files changed, 62 insertions, 0 deletions
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";
+
+