From 5e1220e4b610dfbcde332d9e316eff66ad0bb971 Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期三, 01 一月 2025 21:57:44 +0800 Subject: [PATCH] Merge branch 'master' of http://47.115.28.255:8110/r/TigerClouds-Tech/Server/TigerApi6_2024 --- Tiger.Api/ApiWebHostService.cs | 25 ++++++++++++++++++++++--- 1 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Tiger.Api/ApiWebHostService.cs b/Tiger.Api/ApiWebHostService.cs index 3bead49..3c6a088 100644 --- a/Tiger.Api/ApiWebHostService.cs +++ b/Tiger.Api/ApiWebHostService.cs @@ -6,9 +6,27 @@ using System.Threading.Tasks; using Rhea.Common; using Tiger.IBusiness; +using System.ServiceProcess; +using Tiger.Api.DbCache; namespace Tiger.Api { + public static class WebHostServiceExtensions + { + public static void RunAsApiService(this IWebHost host) + { + try + { + var webHostService = new ApiWebHostService(host); + ServiceBase.Run(webHostService); + } + catch (System.Exception ex) + { + Logger.Console.Fatal(ex, "Windows Services Exception"); + } + } + } + internal class ApiWebHostService : WebHostService { public ApiWebHostService(IWebHost host) : base(host) @@ -38,9 +56,10 @@ //鍏抽棴鏈嶅姟鎬荤嚎 DI.Resolve<IServicesBus>().StopServices(); //鍏抽棴DB缂撳瓨鑷姩鏇存柊 - DI.Resolve<IDbCacheBus>().StopAutoUpdate(); - MQTTHelper.MQTTConn?.Close(); - base.OnStopping(); + //DI.Resolve<IDbCacheBus>().StopAutoUpdate(); + DbCacheBus.StopAutoUpdate(); + //MQTTHelper.MQTTConn?.Close(); + base.OnStopping(); } catch (System.Exception ex) { -- Gitblit v1.9.3