Example #1
0
 /// <summary>
 /// 初始化单元日志模块
 /// </summary>
 /// <returns>是否成功</returns>
 private static Boolean InitializeUnitLoggerModule()
 {
     if (!Directory.Exists(AppEnvironment.UnitLogsDirectory))
     {
         try {
             _ = Directory.CreateDirectory(AppEnvironment.UnitLogsDirectory);
         } catch (Exception exception) {
             Helpers.LoggerModuleHelper.TryLog(
                 "Program.InitializeUnitLoggerModule[Error]", $"创建单元日志目录异常,{exception.Message}\n异常堆栈: {exception.StackTrace}");
             return(false);
         }
     }
     return(UnitLoggerModule.Setup(AppEnvironment.UnitLogsDirectory, 1000));
 }
Example #2
0
 /// <summary>
 /// 应用程序退出之前
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void CurrentDomainProcessExit(object sender, EventArgs e)
 {
     //释放远程管理模块
     RemoteControlModule.Dispose();
     //释放单元管理模块,应确保已无单元正在运行
     UnitManageModule.Dispose();
     //释放单元日志模块
     UnitLoggerModule.Dispose();
     //释放单元性能监控模块
     UnitPerformanceCounterModule.Dispose();
     //是否单元网络监控模块
     UnitNetworkCounterModule.Dispose();
     //停止服务
     if (DaemonServiceController != null)
     {
         DaemonServiceController.Stop();
     }
     //释放自身进程引用
     AppMutex.Dispose();
     AppProcess.Dispose();
     //释放日志模块
     Helpers.LoggerModuleHelper.TryLog("Program.CurrentDomainProcessExit[Warning]", "服务主机进程退出");
     LoggerModule.Dispose();
 }