aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
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 @@
1#!/usr/bin/perl
2use strict;
3
4my $max_outstanding = 300;
5
6$ARGV[0] || die "No directory provided for peer information, exiting!\n";
7
8my $directory = $ARGV[0];
9my @config_files = `find $directory -iname gnunet-testing-config*`;
10my @child_arr = {};
11my $count = 0;
12my $outstanding = 0;
13foreach my $file (@config_files)
14{
15 chomp($file);
16 #print "Starting GNUnet peer with config file $file\n";
17 my $pid = fork();
18 if ($pid == -1)
19 {
20 die;
21 }
22 elsif ($pid == 0)
23 {
24 exec "gnunet-arm -q -c $file -s" or die;
25 }
26
27 if ($pid != 0)
28 {
29 push @child_arr, $pid;
30 $count++;
31 $outstanding++;
32 if ($outstanding > $max_outstanding)
33 {
34 for (my $i = 0; $i < $max_outstanding / 5; $i++)
35 {
36 #print "Too many outstanding peers, waiting!\n";
37 waitpid($child_arr[0], 0);
38 shift(@child_arr);
39 $outstanding--;
40 }
41 }
42 }
43}
44
45print "All $count peers started (waiting for them to finish!\n";
46
47while ($outstanding > 0)
48{
49 waitpid($child_arr[0], 0);
50 shift(@child_arr);
51 $outstanding--;
52 if ($outstanding % 50 == 0)
53 {
54 print "All $count peers started (waiting for $outstanding to finish!\n";
55 }
56}
57
58while (wait() != -1) {sleep 1}
59
60print "All $count peers started!\n";
61
62