mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-13 17:22:54 -05:00
Update .NET Core image and log every message
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0.0-preview6-buster-slim-arm32v7 AS base
|
||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0.0-preview7-buster-slim-arm32v7 AS base
|
||||
WORKDIR /app
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.0.100-preview6-buster AS build
|
||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.0.100-preview7-buster AS build
|
||||
WORKDIR /src
|
||||
COPY ["./SerialReader.csproj", "./"]
|
||||
RUN dotnet restore -r linux-arm "SerialReader.csproj"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using ChrisKaczor.HomeMonitor.Weather.Models;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using RabbitMQ.Client;
|
||||
using System;
|
||||
@@ -6,20 +7,16 @@ using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using ChrisKaczor.HomeMonitor.Weather.Models;
|
||||
|
||||
namespace ChrisKaczor.HomeMonitor.Weather.SerialReader
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static IConfiguration _configuration;
|
||||
private static bool _boardStarting;
|
||||
|
||||
private static readonly CancellationTokenSource CancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
private static DateTime _lastLogTime = DateTime.MinValue;
|
||||
private static long _messageCount;
|
||||
private static bool _boardStarting;
|
||||
|
||||
private static void Main()
|
||||
{
|
||||
WriteLog("Starting");
|
||||
@@ -105,6 +102,8 @@ namespace ChrisKaczor.HomeMonitor.Weather.SerialReader
|
||||
continue;
|
||||
}
|
||||
|
||||
WriteLog($"Message received: {message}");
|
||||
|
||||
var weatherMessage = WeatherMessage.Parse(message);
|
||||
|
||||
var messageString = JsonConvert.SerializeObject(weatherMessage);
|
||||
@@ -116,16 +115,6 @@ namespace ChrisKaczor.HomeMonitor.Weather.SerialReader
|
||||
properties.Persistent = true;
|
||||
|
||||
model.BasicPublish(string.Empty, _configuration["Weather:Queue:Name"], properties, body);
|
||||
|
||||
_messageCount++;
|
||||
|
||||
if ((DateTime.Now - _lastLogTime).TotalMinutes < 1)
|
||||
continue;
|
||||
|
||||
WriteLog($"Number of messages received since {_lastLogTime} = {_messageCount}");
|
||||
|
||||
_lastLogTime = DateTime.Now;
|
||||
_messageCount = 0;
|
||||
}
|
||||
catch (TimeoutException)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user