12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System;
- using System.Collections.Generic;
- using System.Threading;
- using CommandLine;
- namespace ET.Server
- {
- internal static class Init
- {
- private static int Main(string[] args)
- {
- AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
- {
- Log.Error(e.ExceptionObject.ToString());
- };
-
- try
- {
-
- Game.AddSingleton<MainThreadSynchronizationContext>();
-
-
- Parser.Default.ParseArguments<Options>(args)
- .WithNotParsed(error => throw new Exception($"命令行格式错误! {error}"))
- .WithParsed(Game.AddSingleton);
-
- Game.AddSingleton<TimeInfo>();
- Game.AddSingleton<Logger>().ILog = new NLogger(Options.Instance.AppType.ToString(), Options.Instance.Process, "../Config/NLog/NLog.config");
- Game.AddSingleton<ObjectPool>();
- Game.AddSingleton<IdGenerater>();
- Game.AddSingleton<EventSystem>();
- Game.AddSingleton<Root>();
-
- ETTask.ExceptionHandler += Log.Error;
- Dictionary<string, Type> types = AssemblyHelper.GetAssemblyTypes(typeof (Game).Assembly);
- EventSystem.Instance.Add(types);
- MongoHelper.Init();
- ProtobufHelper.Init();
-
- Log.Info($"server start........................ {Root.Instance.Scene.Id}");
-
- switch (Options.Instance.AppType)
- {
- case AppType.ExcelExporter:
- {
- Options.Instance.Console = 1;
- ExcelExporter.Export();
- return 0;
- }
- case AppType.Proto2CS:
- {
- Options.Instance.Console = 1;
- Proto2CS.Export();
- return 0;
- }
- }
- }
- catch (Exception e)
- {
- Log.Console(e.ToString());
- }
- return 1;
- }
- }
- }
|