From 6c74bdbefc5fadec9ce203882bda2001a96c786f Mon Sep 17 00:00:00 2001 From: Ruberoid Date: Fri, 18 Jul 2025 16:57:33 +0300 Subject: [PATCH] Fixed nice configs. --- .gitignore | 2 +- .../Infrastructure/HostBuilderFactory.cs | 4 +-- .../Infrastructure/Startup.cs | 8 ----- .../appsettings.Development.json | 15 --------- .../appsettings.DockerCompose.json | 28 ---------------- .../appsettings.Production.json | 28 ---------------- .../appsettings.json | 16 ++++++++- .../appsettings.k8s.json | 33 ------------------- 8 files changed, 18 insertions(+), 116 deletions(-) delete mode 100644 src/Nocr.TelegramListener.Host/appsettings.Development.json delete mode 100644 src/Nocr.TelegramListener.Host/appsettings.DockerCompose.json delete mode 100644 src/Nocr.TelegramListener.Host/appsettings.Production.json delete mode 100644 src/Nocr.TelegramListener.Host/appsettings.k8s.json diff --git a/.gitignore b/.gitignore index 4098480..8153c72 100644 --- a/.gitignore +++ b/.gitignore @@ -230,6 +230,6 @@ Thumbs.db .idea/ # custom -/**/**/appsettings.protected.json +/**/**/appsettings.*.json **/**/deployment.yml diff --git a/src/Nocr.TelegramListener.Host/Infrastructure/HostBuilderFactory.cs b/src/Nocr.TelegramListener.Host/Infrastructure/HostBuilderFactory.cs index ddf0ff3..adc35a7 100644 --- a/src/Nocr.TelegramListener.Host/Infrastructure/HostBuilderFactory.cs +++ b/src/Nocr.TelegramListener.Host/Infrastructure/HostBuilderFactory.cs @@ -7,14 +7,14 @@ public class HostBuilderFactory where TStartup : class public IHostBuilder CreateHostBuilder(string[] args, string? baseDirectory = null) { var builder = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(host => { host.UseStartup(); }) .ConfigureAppConfiguration((_, configurationBuilder) => { if (!string.IsNullOrWhiteSpace(baseDirectory)) configurationBuilder.SetBasePath(baseDirectory); - configurationBuilder.AddJsonFile(".secrets/appsettings.protected.json", true); + configurationBuilder.AddJsonFile("appsettings.protected.json", optional: true); }) - .ConfigureWebHostDefaults(host => { host.UseStartup(); }) .UseSerilog((ctx, logBuilder) => { logBuilder.ReadFrom.Configuration(ctx.Configuration) diff --git a/src/Nocr.TelegramListener.Host/Infrastructure/Startup.cs b/src/Nocr.TelegramListener.Host/Infrastructure/Startup.cs index 57c99d3..bc03edb 100644 --- a/src/Nocr.TelegramListener.Host/Infrastructure/Startup.cs +++ b/src/Nocr.TelegramListener.Host/Infrastructure/Startup.cs @@ -31,14 +31,6 @@ public class Startup builder.Transport(t => { var rebusOptions = ctx.GetRequiredService>().Value; - - Console.WriteLine("*** DEBUG ***"); - - Console.WriteLine(Environment.GetEnvironmentVariable("RebusRabbitMqOptions__ConnectionString")); - Console.WriteLine(rebusOptions.ConnectionString); - - Console.WriteLine("*** DEBUG ***"); - t.UseRabbitMq(rebusOptions.ConnectionString, rebusOptions.InputQueueName) .DefaultQueueOptions(queue => queue.SetDurable(true)) .ExchangeNames(rebusOptions.DirectExchangeName, rebusOptions.TopicsExchangeName); diff --git a/src/Nocr.TelegramListener.Host/appsettings.Development.json b/src/Nocr.TelegramListener.Host/appsettings.Development.json deleted file mode 100644 index 2d26fac..0000000 --- a/src/Nocr.TelegramListener.Host/appsettings.Development.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Serilog": { - "WriteTo": [ - { - "Name": "Console", - "Args": { - "outputTemplate": "[{Level:u3}] {Timestamp:MM-dd HH:mm:ss} {TraceId} {SourceContext:l} {Message:lj}{NewLine}{Exception}" - } - } - ] - }, - "RebusRabbitMqOptions": { - "ConnectionString": "amqp://admin:admin@localhost:5672/" - } -} diff --git a/src/Nocr.TelegramListener.Host/appsettings.DockerCompose.json b/src/Nocr.TelegramListener.Host/appsettings.DockerCompose.json deleted file mode 100644 index 9d8e995..0000000 --- a/src/Nocr.TelegramListener.Host/appsettings.DockerCompose.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Serilog": { - "MinimumLevel": { - "Default": "Information" - }, - "WriteTo": [ - { - "Name": "Console", - "Args": { - "outputTemplate": "[{Level:u3}] {Timestamp:MM-dd HH:mm:ss} {TraceId} {SourceContext:l} {Message:lj}{NewLine}{Exception}" - } - }, - { - "Name": "File", - "Args": { - "path": "/var/log/nocr/telegram-listener/telegram-listener-.log", - "outputTemplate": "[{Level:u3}] {Timestamp:dd-MM-yyyy HH:mm:ss} {TraceId} {SourceContext:l} {Message:lj}{NewLine}{Exception}", - "fileSizeLimitBytes": 104857600, - "rollingInterval": "Day", - "rollOnFileSizeLimit": true - } - } - ] - }, - "RebusRabbitMqOptions": { - "ConnectionString": "amqp://admin:admin@nocr-rabbitmq:5672/" - } -} \ No newline at end of file diff --git a/src/Nocr.TelegramListener.Host/appsettings.Production.json b/src/Nocr.TelegramListener.Host/appsettings.Production.json deleted file mode 100644 index 6e77733..0000000 --- a/src/Nocr.TelegramListener.Host/appsettings.Production.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Serilog": { - "MinimumLevel": { - "Default": "Information" - }, - "WriteTo": [ - { - "Name": "Console", - "Args": { - "outputTemplate": "[{Level:u3}] {Timestamp:MM-dd HH:mm:ss} {TraceId} {SourceContext:l} {Message:lj}{NewLine}{Exception}" - } - }, - { - "Name": "File", - "Args": { - "path": "/var/log/nocr/telegram-listener/telegram-listener-.log", - "outputTemplate": "[{Level:u3}] {Timestamp:dd-MM-yyyy HH:mm:ss} {TraceId} {SourceContext:l} {Message:lj}{NewLine}{Exception}", - "fileSizeLimitBytes": 104857600, - "rollingInterval": "Day", - "rollOnFileSizeLimit": true - } - } - ] - }, - "RebusRabbitMqOptions": { - "ConnectionString": "" - } -} \ No newline at end of file diff --git a/src/Nocr.TelegramListener.Host/appsettings.json b/src/Nocr.TelegramListener.Host/appsettings.json index 1526fec..a06c301 100644 --- a/src/Nocr.TelegramListener.Host/appsettings.json +++ b/src/Nocr.TelegramListener.Host/appsettings.json @@ -7,11 +7,25 @@ "Microsoft.AspNetCore": "Error", "System.Net.Http.HttpClient": "Warning" } - } + }, + "WriteTo": [ + { + "Name": "Console", + "Args": { + "outputTemplate": "[{Level:u3}] {Timestamp:MM-dd HH:mm:ss} {TraceId} {SourceContext:l} {Message:lj}{NewLine}{Exception}" + } + } + ] }, "RebusRabbitMqOptions": { + "ConnectionString": "", "InputQueueName": "nocr.telegram.listener.queue", "DirectExchangeName": "nocr.direct", "TopicsExchangeName": "nocr.topics" + }, + "WTelegramClientOptions": { + "ApiId": "", + "ApiHash": "", + "PhoneNumber": "" } } \ No newline at end of file diff --git a/src/Nocr.TelegramListener.Host/appsettings.k8s.json b/src/Nocr.TelegramListener.Host/appsettings.k8s.json deleted file mode 100644 index dede7c2..0000000 --- a/src/Nocr.TelegramListener.Host/appsettings.k8s.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "Serilog": { - "MinimumLevel": { - "Default": "Debug" - }, - "WriteTo": [ - { - "Name": "Console", - "Args": { - "outputTemplate": "[{Level:u3}] {Timestamp:MM-dd HH:mm:ss} {TraceId} {SourceContext:l} {Message:lj}{NewLine}{Exception}" - } - }, - { - "Name": "File", - "Args": { - "path": "/var/log/nocr/telegram-listener/telegram-listener-.log", - "outputTemplate": "[{Level:u3}] {Timestamp:dd-MM-yyyy HH:mm:ss} {TraceId} {SourceContext:l} {Message:lj}{NewLine}{Exception}", - "fileSizeLimitBytes": 104857600, - "rollingInterval": "Day", - "rollOnFileSizeLimit": true - } - } - ] - }, - "RebusRabbitMqOptions": { - "ConnectionString": "" - }, - "WTelegramClientOptions": { - "ApiId": "", - "ApiHash": "", - "PhoneNumber": "" - } -}