Beispiel #1
0
        public static void Test(Server s)
        {
            DateTime start   = DateTime.Now;
            DateTime timeout = DateTime.Now.Add(Timeout);

            s.SendCommand("whitelist");
            while (true)
            {
                if (s.LastReceived > start)
                {
                    break;
                }
#if DEBUG
                Console.WriteLine("Watchdog waiting");
#endif
                if (DateTime.Now < timeout)
                {
                    System.Threading.Thread.Sleep(100);
                    continue;
                }
                //Triggered
                BackendManager.Log(new Exception("Watchdog: " + s.Name));
                s.Kill();
                break;
            }
        }
Beispiel #2
0
        public static void Test(Server s)
        {
            DateTime start = DateTime.Now;
            DateTime timeout = DateTime.Now.Add(Timeout);
            s.SendCommand("whitelist");
            while (true)
            {
                if (s.LastReceived > start)
                    break;
#if DEBUG
                Console.WriteLine("Watchdog waiting");
#endif
                if (DateTime.Now < timeout)
                {
                    System.Threading.Thread.Sleep(100);
                    continue;
                }
                //Triggered
                BackendManager.Log(new Exception("Watchdog: " + s.Name));
                s.Kill();
                break;
            }
        }
Beispiel #3
0
        void ParseCommand(string[] args)
        {
            switch (args [0])
            {
            case "list":
                SendLine(BackendManager.RunningServers());
                return;

            case "shutdown":
                Console.WriteLine("Got Shutdown command");
                SendLine("shutting down");
                Program.Shutdown((args.Length > 1) ? string.Join(" ", args, 1, args.Length - 1) : "Admin initated restart");
                active = false;
                return;

            case "exit":     //Close client connection
                SendLine("bye");
                active = false;
                return;

            case "stop":
                if (args.Length != 2)
                {
                    throw new InvalidArgumentException("Usage: stop <name>");
                }

                Console.WriteLine("Got Suspend command: " + args [1]);
                if (BackendManager.StopServer(args [1]))
                {
                    SendLine("stopped " + args [1]);
                }
                else
                {
                    SendLine("not running " + args [1]);
                }
                return;

            case "start":
                if (args.Length < 2)
                {
                    throw new InvalidArgumentException("Usage: start <name>");
                }

                Console.WriteLine("Got Resume command");
                Server s = BackendManager.StartServer(args [1]);
                SendLine("running\t" + s);
                return;
            }

            if (BlockSaveCommand && args [0].StartsWith("save"))
            {
                return;
            }

            //Vanilla commands
            if (args.Length < 2)
            {
                throw new InvalidArgumentException("Usage: <serverName> command");
            }

            Server server = BackendManager.GetServer(args [0]);

            if (server == null)
            {
                throw new InvalidArgumentException("No such running server: " + args [0]);
            }

            server.SendCommand(string.Join(" ", args, 1, args.Length - 1));
        }