protected void LaunchProcess(string processType, string args)
 {
     if (Ip.Equals("localhost") || Ip.Equals("127.0.0.1"))
     {
         if (Util.IsLinux)
         {
             Process.Start("mono",
                           string.Join(" ", Util.PROJECT_ROOT + processType +
                                       Util.EXE_PATH + processType + ".exe", args));
         }
         else
         {
             Process.Start(Util.PROJECT_ROOT + processType +
                           Util.EXE_PATH + processType, args);
         }
     }
     else
     {
         IPuppetMasterLauncher launcher = Activator.GetObject(
             typeof(IPuppetMasterLauncher), Util.MakeUrl("tcp",
                                                         Ip, Util.PUPPET_MASTER_PORT.ToString(), Util.PUPPET_MASTER_NAME))
                                          as IPuppetMasterLauncher;
         launcher.LaunchProcess(processType, args);
     }
 }
示例#2
0
        public void exec(string className, string ip, string port, string args)
        {
            if (ip.Equals("localhost") || ip.Equals("127.0.0.1") || ip.Equals(Util.GetLocalIPAddress()))
            {
                if (Util.IsLinux)
                {
                    processes.Add(args.Split(' ')[0], Process.Start("mono",
                                                                    string.Join(" ", Util.PROJECT_ROOT + className +
                                                                                Util.EXE_PATH + className + ".exe", args)));
                }
                else
                {
                    Console.WriteLine("Localhost Launching Process... " + Util.PROJECT_ROOT + className +
                                      Util.EXE_PATH + className + "\r\n" + args);
                    processes.Add(args.Split(' ')[0], Process.Start(Util.PROJECT_ROOT + className +
                                                                    Util.EXE_PATH + className, args));
                }
            }
            else
            {
                string url = Util.MakeUrl("tcp", ip, Util.portPCS.ToString(), Util.PCS);
                IPuppetMasterLauncher launcher = Activator.GetObject(
                    typeof(IPuppetMasterLauncher), url)
                                                 as IPuppetMasterLauncher;
                pcs.Add(args.Split(' ')[0], launcher);
                Console.WriteLine("Launching Process on other PC: " + url);
                try
                {
                    launcher.LaunchProcess(className, args);
                }catch (Exception e)
                {
                    Console.WriteLine("Connect to other pc fail: " + e);
                }
            }
            IGeneralControlServices service = Activator.GetObject(
                typeof(IGeneralControlServices), args.Split(' ')[2])
                                              as IGeneralControlServices;

            remotingProcesses.Add(args.Split(' ')[0], service);
        }