using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace NGridMultiTest{
class Program
{
static void Main(string[] args)
{
int n = 2;
if (args != null && args.Length >= 1)
{
n = Int32.Parse(args[0]);
}
int[] ports = new int[n];
Process[] workers = new Process[n];
string[] hosts = new string[n];
ProcessStartInfo processInfo;
int portStart = 1234;
for (int i = 0; i < n; i++)
{
int port = i + portStart;
processInfo = new ProcessStartInfo("NGridPlasma.exe", port.ToString());
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = false;
Console.WriteLine("Dmarrage du worker {0}...", i + 1);
workers[i] = Process.Start(processInfo);
hosts[i] = "localhost:" + port.ToString();
}
string arguments = "--no-dgc " + String.Join(" ", hosts) + " NGridTest.exe 20";
processInfo = new ProcessStartInfo("NGridPlasma.exe", arguments);
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = true;
Console.WriteLine("Dmarrage du programme test sur les {0} workers...", n);
Process loader = Process.Start(processInfo);
// Redirects the error stream of the process "loader" to the output stream of the current process.
string output = loader.StandardOutput.ReadToEnd();
Console.WriteLine(output);
ConsoleKeyInfo cki;
while (true)
{
cki = Console.ReadKey();
if (cki.Key == ConsoleKey.Escape)
break;
}
try
{
for (int i = 0; i < n; i++)
{
workers[i].Kill();
}
}
catch { }
}
}
}
|