Make telegram client config much more nicer.

This commit is contained in:
Ruberoid 2025-07-18 16:41:07 +03:00
parent f25f3429cb
commit ea27d8d448
7 changed files with 27 additions and 136 deletions

2
.gitignore vendored
View File

@ -226,6 +226,6 @@ Thumbs.db
.idea/ .idea/
# custom # custom
/**/**/appsettings.protected.json /**/**/appsettings.*.json
**/**/deployment.yml **/**/deployment.yml

View File

@ -7,14 +7,14 @@ public class HostBuilderFactory<TStartup> where TStartup : class
public IHostBuilder CreateHostBuilder(string[] args, string? baseDirectory = null) public IHostBuilder CreateHostBuilder(string[] args, string? baseDirectory = null)
{ {
var builder = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args) var builder = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(host => { host.UseStartup<TStartup>(); })
.ConfigureAppConfiguration((_, configurationBuilder) => .ConfigureAppConfiguration((_, configurationBuilder) =>
{ {
if (!string.IsNullOrWhiteSpace(baseDirectory)) if (!string.IsNullOrWhiteSpace(baseDirectory))
configurationBuilder.SetBasePath(baseDirectory); configurationBuilder.SetBasePath(baseDirectory);
configurationBuilder.AddJsonFile("appsettings.protected.json", true); configurationBuilder.AddJsonFile("appsettings.protected.json", optional: true);
}) })
.ConfigureWebHostDefaults(host => { host.UseStartup<TStartup>(); })
.UseSerilog((ctx, logBuilder) => .UseSerilog((ctx, logBuilder) =>
{ {
logBuilder.ReadFrom.Configuration(ctx.Configuration) logBuilder.ReadFrom.Configuration(ctx.Configuration)

View File

@ -1,24 +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/"
},
"UsersRestEaseOptions": {
"BasePath": "http://localhost:4998"
},
"TextMatcherRestEaseOptions": {
"BasePath": "http://localhost:5001"
},
"AdministrationOptions": {
"EnableUpdateTelegramLogging": false
}
}

View File

@ -1,39 +0,0 @@
{
"Serilog": {
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Information",
"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}"
}
},
{
"Name": "File",
"Args": {
"path": "/var/log/nocr/telegram-client/telegram-client-.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/"
},
"UsersRestEaseOptions": {
"BasePath": "http://nocr-users:8080"
},
"TextMatcherRestEaseOptions": {
"BasePath": "http://nocr-text-matcher:8080"
}
}

View File

@ -1,25 +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-client/nocr-telegram-client-.log",
"outputTemplate": "[{Level:u3}] {Timestamp:dd-MM-yyyy HH:mm:ss} {TraceId} {SourceContext:l} {Message:lj}{NewLine}{Exception}",
"fileSizeLimitBytes": 104857600,
"rollingInterval": "Day",
"rollOnFileSizeLimit": true
}
}
]
}
}

View File

@ -7,13 +7,36 @@
"Microsoft.AspNetCore": "Error", "Microsoft.AspNetCore": "Error",
"System.Net.Http.HttpClient": "Warning" "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": { "RebusRabbitMqOptions": {
"ConnectionString": "",
"InputQueueName": "nocr.telegram.client.queue", "InputQueueName": "nocr.telegram.client.queue",
"DirectExchangeName": "nocr.direct", "DirectExchangeName": "nocr.direct",
"TopicsExchangeName": "nocr.topics" "TopicsExchangeName": "nocr.topics"
}, },
"UsersRestEaseOptions": {
"BasePath": ""
},
"TextMatcherRestEaseOptions": {
"BasePath": ""
},
"TelegramBotOptions": {
"Token": ""
},
"AdministrationOptions": {
"EnableUpdateTelegramLogging": false,
"FeedbackReceiverIds": [],
"UpdateReceiverIds": []
},
"MessageDispatcherOptions": { "MessageDispatcherOptions": {
"Interval": "00:00:00.050", "Interval": "00:00:00.050",
"ExceptionInterval": "00:00:30" "ExceptionInterval": "00:00:30"
@ -22,9 +45,5 @@
"Path": "Resources", "Path": "Resources",
"Pattern": "", "Pattern": "",
"ReadNestedFolders": "true" "ReadNestedFolders": "true"
},
"AdministrationOptions": {
"FeedbackReceiverIds": [],
"UpdateReceiverIds": []
} }
} }

View File

@ -1,40 +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-client/nocr-telegram-client-.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": ""
},
"UsersRestEaseOptions": {
"BasePath": ""
},
"TextMatcherRestEaseOptions": {
"BasePath": ""
},
"TelegramBotOptions": {
"Token": ""
},
"AdministrationOptions": {
"EnableUpdateTelegramLogging": true
}
}