服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-11-19 8c998a765b56cba071e4d41f417589f6c0159dce
Tiger.Api/ApiWebHostService.cs
@@ -6,9 +6,26 @@
using System.Threading.Tasks;
using Rhea.Common;
using Tiger.IBusiness;
using System.ServiceProcess;
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)
@@ -39,7 +56,7 @@
                DI.Resolve<IServicesBus>().StopServices();
                //关闭DB缓存自动更新
                DI.Resolve<IDbCacheBus>().StopAutoUpdate();
                MQTTHelper.MQTTConn?.Close();
                //MQTTHelper.MQTTConn?.Close();
               base.OnStopping();
            }
            catch (System.Exception ex)