gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r14657 - gnunet/contrib


From: gnunet
Subject: [GNUnet-SVN] r14657 - gnunet/contrib
Date: Tue, 15 Mar 2011 12:00:36 +0100

Author: nevans
Date: 2011-03-15 12:00:36 +0100 (Tue, 15 Mar 2011)
New Revision: 14657

Added:
   gnunet/contrib/peerStartHelper.pl
Log:
helper process that rather dumbly starts gnunet peers

Added: gnunet/contrib/peerStartHelper.pl
===================================================================
--- gnunet/contrib/peerStartHelper.pl                           (rev 0)
+++ gnunet/contrib/peerStartHelper.pl   2011-03-15 11:00:36 UTC (rev 14657)
@@ -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";
+
+


Property changes on: gnunet/contrib/peerStartHelper.pl
___________________________________________________________________
Added: svn:executable
   + *




reply via email to

[Prev in Thread] Current Thread [Next in Thread]