diff --git a/HealthMonitor.Service/Sub/TDengineDataSubcribe.cs b/HealthMonitor.Service/Sub/TDengineDataSubcribe.cs index f3c950f..102de70 100644 --- a/HealthMonitor.Service/Sub/TDengineDataSubcribe.cs +++ b/HealthMonitor.Service/Sub/TDengineDataSubcribe.cs @@ -87,7 +87,8 @@ namespace HealthMonitor.Service.Sub var conn = TDengine.Connect(host, username, password, dbname, port); if (conn == IntPtr.Zero) { - throw new Exception("Connect to TDengine failed"); + _logger.LogError("reason:" + TDengine.Error(conn)); + throw new Exception("Connect to TDengine failed"+DateTime.Now.ToString()); } else { diff --git a/HealthMonitor.WebApi/Controllers/WeatherForecastController.cs b/HealthMonitor.WebApi/Controllers/WeatherForecastController.cs index e5dc128..ca632c8 100644 --- a/HealthMonitor.WebApi/Controllers/WeatherForecastController.cs +++ b/HealthMonitor.WebApi/Controllers/WeatherForecastController.cs @@ -34,24 +34,24 @@ namespace HealthMonitor.WebApi.Controllers // .ToArray(); //} - [HttpGet(Name = "GetWeatherForecast")] - public async Task Get() - { - IntPtr conn = _serviceTDengine.Connection(); - var sql = "select * from gps_bloodpress"; - //Task.Factory.StartNew(async () => - //{ - // await _serviceTDengine.ExecuteQuerySQL(conn, sql); - //}); + //[HttpGet(Name = "GetWeatherForecast")] + //public async Task Get() + //{ + // IntPtr conn = _serviceTDengine.Connection(); + // var sql = "select * from gps_bloodpress"; + // //Task.Factory.StartNew(async () => + // //{ + // // await _serviceTDengine.ExecuteQuerySQL(conn, sql); + // //}); - _serviceTDengine.ExecuteQuerySQL(conn, sql); + // _serviceTDengine.ExecuteQuerySQL(conn, sql); - //var res= await _serviceAliIot.QueryDeviceStatisticseAsync(nameof(Get)); - //var online = res?.OnlineCount; - return Ok("aa"); + // //var res= await _serviceAliIot.QueryDeviceStatisticseAsync(nameof(Get)); + // //var online = res?.OnlineCount; + // return Ok("aa"); - } + //} } } \ No newline at end of file diff --git a/HealthMonitor.WebApi/Dockerfile b/HealthMonitor.WebApi/Dockerfile index 0b204e2..9dda4f6 100644 --- a/HealthMonitor.WebApi/Dockerfile +++ b/HealthMonitor.WebApi/Dockerfile @@ -8,10 +8,26 @@ RUN sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list RUN sed -i s@/security.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list RUN apt-get update --fix-missing\ - && DEBIAN_FRONTEND=noninteractive apt-get install -y net-tools vim \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y net-tools vim wget curl tar\ && apt-get clean \ && rm -rf /var/lib/apt/lists/* +# 安装 TDengine 客户端 +RUN curl -o /tmp/TDengine-client-3.0.4.2-Linux-x64.tar.gz https://www.taosdata.com/assets-download/3.0/TDengine-client-3.0.4.2-Linux-x64.tar.gz + +WORKDIR /tmp + +# 解压 +RUN tar xvf TDengine-client-3.0.4.2-Linux-x64.tar.gz +RUN ls +# 切换文件夹 +WORKDIR /tmp/TDengine-client-3.0.4.2 +RUN ls +# 执行安装脚本 +RUN bash install_client.sh +# 设置 TDengine 服务器的 End Point +RUN echo "firstEp 47.116.142.20:6030" >> /etc/taos/taos.cfg + FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY ["nuget.config","."] diff --git a/HealthMonitor.WebApi/PackageProcess.cs b/HealthMonitor.WebApi/PackageProcess.cs index 1c62f6f..db03112 100644 --- a/HealthMonitor.WebApi/PackageProcess.cs +++ b/HealthMonitor.WebApi/PackageProcess.cs @@ -34,7 +34,7 @@ namespace HealthMonitor.WebApi { Console.WriteLine(ex.Message); - //_logger.LogError($"[{msg.MessageId}] 鏈鐞嗗紓甯 message: {ex.Message}\n {ex.StackTrace}"); + _logger.LogError($"鏈鐞嗗紓甯 message: {ex.Message}\n {ex.StackTrace}"); } return true; diff --git a/HealthMonitor.WebApi/Worker.cs b/HealthMonitor.WebApi/Worker.cs index a459e21..c43d6bc 100644 --- a/HealthMonitor.WebApi/Worker.cs +++ b/HealthMonitor.WebApi/Worker.cs @@ -50,9 +50,10 @@ namespace HealthMonitor.WebApi if (_tokenSource.IsCancellationRequested) _logger.LogWarning("Worker exit"); + _logger.LogInformation("------ResolveAsync"); while (!_tokenSource.IsCancellationRequested) { - + // await _processor.ResolveAsync().ConfigureAwait(false); // await _tdEngineDataSubcribe.ProcessMsg(); } @@ -61,8 +62,10 @@ namespace HealthMonitor.WebApi factory.StartNew(() => { + _logger.LogInformation("------_tdEngineDataSubcribe"); while (!_tokenSource.IsCancellationRequested) { + _tdEngineDataSubcribe.BeginListen(_tokenSource.Token); } }, TaskCreationOptions.LongRunning);