Esempio n. 1
0
 public static void ListenForNewConnections()
 {
     if (!Program.ShutDown && server.Pending())
     {
         TcpClient client = server.AcceptTcpClient();
         BismuthThreadPool.StartThread(HandleClientThread, client);
     }
 }
Esempio n. 2
0
        static void RunBismuth(string[] args)
        {
            //Load plugins
            if (!BismuthConfig.Setup())
            {
                return;
            }

            BismuthThreadPool.Setup();
            SetupManagersFromLoadedAssemblies();

            ModeFlagBindings.AddBindings("HELP", "Displays this help text", new string[] { "h", "help" });
            RCONServer.AddRCONCommand("version", "Lists the Bismuth version information", (a) => { return(Program.GetFullProgramVersionString()); });
            RCONServer.AddRCONCommand("status", "Lists various statistics about the current Bismuth process", (a) => { return(GetStatus(true)); });
            RCONServer.AddRCONCommand("list-managers", "Lists all currently running managers", (a) => { return(ListManagers(true)); });

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i][0] == '-')
                {
                    if (args[i][1] == '-')
                    {
                        ModeFlagBindings.SetFlag(args[i].Substring(2));
                    }
                    else
                    {
                        for (int j = 1; j < args[i].Length; j++)
                        {
                            ModeFlagBindings.SetFlag(args[i][j]);
                        }
                    }
                }
            }

            if (ModeFlagBindings.IsFlagSet("HELP"))
            {
                ModeFlagBindings.PrintHelp();
                return;
            }

            LogManager.Log("Main Thread", "Beginning primary execution loop");
            while (!ShutDown)
            {
                //TODO: Handle plugin receive handler
                NetworkManager.ListenForNewConnections();
                Thread.Sleep(1);
            }
            LogManager.Log("Main Thread", "Primary execution loop quit");
        }
Esempio n. 3
0
        static void Shutdown()
        {
            if (shutdownMethodCalled)
            {
                return;
            }

            shutdownMethodCalled = ShutDown = true;

            LogManager.Log("SHUTDOWN", "Beginning Bismuth shutdown");
            ShutdownManagers();
            BismuthThreadPool.Shutdown();
            LogManager.Log("SHUTDOWN", "Bismuth shutdown complete");
            Console.ReadKey();
        }
Esempio n. 4
0
        public static string GetStatus(bool bSilent = false)
        {
            StringBuilder toReturn          = new StringBuilder();
            Process       currentProcess    = Process.GetCurrentProcess();
            TimeSpan      Uptime            = DateTime.Now - LaunchTime;
            TimeSpan      TrueProcessorTime = TimeSpan.FromTicks(currentProcess.TotalProcessorTime.Ticks / Environment.ProcessorCount);

            toReturn.Append("Server status at " + DateTime.Now.ToString("r") + "\r\n");
            toReturn.Append("     Server Started: " + LaunchTime.ToString("r") + "\r\n");
            toReturn.Append("             Uptime: " + Uptime + "\r\n");
            toReturn.Append("     Total CPU Time: " + TrueProcessorTime + " on " + Environment.ProcessorCount + " cores\r\n");
            toReturn.Append("  Average CPU Usage: " + (100 * ((TrueProcessorTime.TotalMilliseconds * Environment.ProcessorCount) / Uptime.TotalMilliseconds)) + "%\r\n");
            toReturn.Append("    Total RAM Usage: " + (currentProcess.WorkingSet64 / 1024 / 1024) + "MB\r\n");
            toReturn.Append("   Thread Pool Info:\r\n");
            toReturn.Append("                    " + BismuthThreadPool.GetActiveThreadCount() + " active threads\r\n");
            toReturn.Append("                    " + BismuthThreadPool.GetTotalPossibleThreads() + " free threads\r\n");
            toReturn.Append("                    " + BismuthThreadPool.GetPendingTaskCount() + " tasks waiting\r\n");
            return(toReturn.ToString());
        }