File: 1.11.1b/server/bin/test-threaded.php (View as HTML)

  1: <?php
  2: require("include.php");
  3: $NATS->Start();
  4: 
  5: $nodelist=array();
  6: for ($a=1; $a<$argc; $a++)
  7: 	$nodelist[]=$argv[$a];
  8: 
  9: 
 10: echo "test-threaded.sh: spawning node tester processes\n";
 11: 
 12: $q="SELECT nodeid FROM fnnode WHERE nodeenabled>0";
 13: if (count($nodelist)>0) 
 14: 	{
 15: 	$q.=" AND nodeid IN(";
 16: 	$first=true;
 17: 	foreach($nodelist as $node)
 18: 		{
 19: 		if ($first) $first=false;
 20: 		else $q.=",";
 21: 		$q.="\"".ss($node)."\"";
 22: 		}
 23: 	$q.=")";
 24: 	}
 25: else $q.=" AND masterid=\"\"";
 26: 
 27: $q.=" ORDER BY weight ASC";
 28: 
 29: $r=$NATS->DB->Query($q);
 30: $spawn_delay=$NATS->Cfg->Get("test.spawndelay",0);
 31: //echo "Delay: ".$spawn_delay."\n";
 32: if ($spawn_delay>0) $spawn_delay=$spawn_delay*1000000; // convert to us (microseconds / millionths)
 33: //echo "Delay: ".$spawn_delay."\n";
 34: $first=true;
 35: while ($row=$NATS->DB->Fetch_Array($r))
 36: 	{
 37: 	if ($first) $first=false;
 38: 	else
 39: 		{
 40: 		// Test Execution Delay / test.spawndelay
 41: 		if ($spawn_delay>0) usleep($spawn_delay);
 42: 		}
 43: 	$cmd="php ./tester.php ".$row['nodeid']." > /tmp/nr.".$row['nodeid']." &";
 44: 	echo $cmd."\n";
 45: 	exec($cmd);
 46: 	}
 47: $NATS->DB->Free($r);
 48: $NATS->Stop();
 49: ?>
 50: 
 51: