/* ########################## Remote Calls ########################## */

        public void Status()
        {
            foreach (KeyValuePair <string, string> pair in processes)
            {
                IGeneralControlServices node = Activator.GetObject(typeof(IGeneralControlServices), pair.Value)
                                               as IGeneralControlServices;
                node.Status();
            }
        }
        public void Unfreeze(string processName)
        {
            if (!processes.ContainsKey(processName))
            {
                return;
            }
            IGeneralControlServices node = Activator.GetObject(typeof(IGeneralControlServices),
                                                               processes[processName]) as IGeneralControlServices;

            logServer.LogAction("Unfreeze " + processName);
            node.Unfreeze();
        }
 public void CrashAll()
 {
     foreach (KeyValuePair <string, string> pair in processes)
     {
         IGeneralControlServices node = Activator.GetObject(typeof(IGeneralControlServices), pair.Value)
                                        as IGeneralControlServices;
         logServer.LogAction("Crash " + pair.Key);
         node.Crash();
     }
     processes.Clear();
     parentForm.BeginInvoke(new Enable(parentForm.EnableConfigFiles), true);
     parentForm.BeginInvoke(new Enable(parentForm.EnableScriptFiles), false);
 }
        public void Crash(string processName)
        {
            if (!processes.ContainsKey(processName))
            {
                return;
            }
            IGeneralControlServices node = Activator.GetObject(typeof(IGeneralControlServices),
                                                               processes[processName]) as IGeneralControlServices;

            logServer.LogAction("Crash " + processName);
            node.Crash();
            processes.Remove(processName);
            if (processes.Count == 0)
            {
                parentForm.BeginInvoke(new Enable(parentForm.EnableConfigFiles), true);
                parentForm.BeginInvoke(new Enable(parentForm.EnableScriptFiles), false);
            }
        }
Example #5
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);
        }