/// <summary>
        /// 初始化,必须先调用
        /// </summary>
        public static void InitializeBase(bool bear)
        {
            if (IsInitialize)
            {
                return;
            }

            IocHelper.Update();
            IocHelper.AddScoped <GlobalContext, BusinessContext>();
            IocHelper.AddSingleton <IZeroPublisher, ZeroNetBridge>();
            IocHelper.AddSingleton <IGlobalContext, BusinessContext>(p => BusinessContext.Context);
            IocHelper.Update();

            Environment.CurrentDirectory = ConfigurationManager.BasePath = HttpContext.Current.Server.MapPath("~");

            LogRecorder.Initialize();
            LogRecorder.SystemLog("启动");
            LogRecorder.GetRequestIdFunc = () => RandomOperate.Generate(8);
            GlobalConfiguration.Configuration.MapHttpAttributeRoutes(new CustomDirectRouteProvider());
            HttpHandler.Handlers.Add(new CorsHandler());
            HttpHandler.Handlers.Add(new HttpIoLogHandler());
            if (bear)
            {
                HttpHandler.Handlers.Add(new BearerHandler());
            }
            IsInitialize = true;
        }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="title"></param>
 /// <param name="messages"></param>
 public static void SystemLog(string title, params object[] messages)
 {
     if (messages.Length == 0)
     {
         LogRecorder.SystemLog(title);
     }
     else
     {
         LogRecorder.SystemLog("{0} : {1}", title, messages.LinkToString(" $ "));
     }
 }
Beispiel #3
0
        private static void ShowOptionInfo()
        {
            StringBuilder info = new StringBuilder();

            info.AppendLine($"  OS : {(RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "Linux" : "Windows")}");
            info.AppendLine($"  RunModel : {ConfigurationManager.Root["ASPNETCORE_ENVIRONMENT_"]}");
            info.AppendLine($"  Name : {Config.StationName} {GlobalContext.ServiceName} {GlobalContext.ServiceRealName} {Config.LocalIpAddress}");

            info.AppendLine($"  RootPath : {Config.RootPath}");
            info.AppendLine($"  LogPath : {LogRecorder.LogPath}");

            ThreadPool.GetMaxThreads(out var worker, out var io);
            info.AppendLine($"  Worker threads: {worker:N0}Asynchronous I / O threads: { io:N0}");
            LogRecorder.SystemLog(info.ToString());
        }