服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
19 小时以前 a960900364d19bbf0ad7923a57989609e7fce798
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)
            {