Beispiel #1
0
 private static void Main(string[] args)
 {
     try
     {
         string exeFile = Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;
         string version = Program.GetVersionDateTime();
         Console.Title = string.Format("跨服中心服务器@{0}@{1}", version, exeFile);
         File.WriteAllText("Pid.txt", Process.GetCurrentProcess().Id.ToString());
         FileStream fs = File.Open("Pid.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Fatal, "本程序已经启动了一个进程,按任意键退出!", ex, true);
         return;
     }
     if (args.Contains("-gmsettime"))
     {
         KuaFuServerManager.EnableGMSetAllServerTime = true;
     }
     if (args.Contains("-testmode"))
     {
         Global.TestMode = true;
         Consts.TestMode = true;
     }
     if (args.Contains("-waitdebug"))
     {
         Console.WriteLine("等待调试器连接,按任意键继续!");
         do
         {
             Thread.Sleep(100);
         }while (!Console.KeyAvailable);
         Console.ReadKey();
     }
     Program.HideCloseBtn();
     Program.SetConsoleCtrlHandler(Program.newDelegate, true);
     if (Console.WindowWidth < 88)
     {
         Console.BufferWidth = 88;
         Console.WindowWidth = 88;
     }
     Console.WriteLine("跨服中心服务器启动!");
     LogManager.WriteLog(LogTypes.Info, "跨服中心服务器启动!", null, true);
     if (!KuaFuServerManager.CheckConfig())
     {
         Console.WriteLine("服务器无法启动!");
         Thread.Sleep(300000);
     }
     else
     {
         RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
         KuaFuServerManager.StartServerConfigThread();
         if (!KuaFuServerManager.LoadConfig())
         {
             Console.WriteLine("服务器无法启动!");
             Thread.Sleep(300000);
         }
         else
         {
             KuaFuServerManager.InitServer();
             Program.StartServices();
             Program.InitCmdDict();
             KuaFuServerManager.OnStartServer();
             new Thread(new ParameterizedThreadStart(Program.ConsoleInputThread))
             {
                 IsBackground = true
             }.Start();
             while (!KuaFuServerManager.WaitStop(0))
             {
                 Thread.Sleep(1000);
             }
         }
     }
 }