Add Multi Instance Support , Serilog , little Hotfixes
This commit is contained in:
@@ -1,27 +1,45 @@
|
||||
using System.Net;
|
||||
using Serilog;
|
||||
using Serilog.Filters;
|
||||
using UmlautAdaptarr.Options;
|
||||
using UmlautAdaptarr.Routing;
|
||||
using UmlautAdaptarr.Services;
|
||||
using UmlautAdaptarr.Services.Factory;
|
||||
using UmlautAdaptarr.Utilities;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
|
||||
|
||||
Helper.ShowLogo();
|
||||
|
||||
// TODO:
|
||||
// add option to sort by nzb age
|
||||
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var configuration = builder.Configuration;
|
||||
|
||||
// TODO workaround to not log api keys
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(configuration)
|
||||
.WriteTo.Console(outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")
|
||||
.Filter.ByExcluding(Matching.FromSource("System.Net.Http.HttpClient"))
|
||||
.Filter.ByExcluding(Matching.FromSource("Microsoft.Extensions.Http.DefaultHttpClientFactory"))
|
||||
//.Enrich.With(new ApiKeyMaskingEnricher("appsettings.json")) // Not Work currently
|
||||
.CreateLogger();
|
||||
|
||||
|
||||
|
||||
builder.Services.AddSerilog();
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddHttpClient("HttpClient").ConfigurePrimaryHttpMessageHandler(() =>
|
||||
{
|
||||
var handler = new HttpClientHandler
|
||||
{
|
||||
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate | DecompressionMethods.Brotli
|
||||
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate |
|
||||
DecompressionMethods.Brotli
|
||||
};
|
||||
|
||||
var proxyOptions = configuration.GetSection("Proxy").Get<ProxyOptions>();
|
||||
@@ -36,19 +54,7 @@ internal class Program
|
||||
});
|
||||
|
||||
|
||||
// TODO workaround to not log api keys
|
||||
builder.Logging.AddFilter((category, level) =>
|
||||
{
|
||||
// Prevent logging of HTTP request and response if the category is HttpClient
|
||||
if (category.Contains("System.Net.Http.HttpClient") || category.Contains("Microsoft.Extensions.Http.DefaultHttpClientFactory"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddHostedService<ArrSyncBackgroundService>();
|
||||
builder.AddTitleLookupService();
|
||||
builder.Services.AddSingleton<SearchItemLookupService>();
|
||||
builder.Services.AddSingleton<TitleMatchingService>();
|
||||
@@ -57,6 +63,8 @@ internal class Program
|
||||
builder.AddReadarrSupport();
|
||||
builder.Services.AddSingleton<CacheService>();
|
||||
builder.Services.AddSingleton<ProxyRequestService>();
|
||||
builder.Services.AddSingleton<RrApplicationFactory>();
|
||||
builder.Services.AddHostedService<ArrSyncBackgroundService>();
|
||||
builder.Services.AddSingleton<IHostedService, HttpProxyService>();
|
||||
|
||||
var app = builder.Build();
|
||||
@@ -65,36 +73,35 @@ internal class Program
|
||||
app.UseHttpsRedirection();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllerRoute(name: "caps",
|
||||
pattern: "{options}/{*domain}",
|
||||
defaults: new { controller = "Caps", action = "Caps" },
|
||||
constraints: new { t = new TRouteConstraint("caps") });
|
||||
app.MapControllerRoute("caps",
|
||||
"{options}/{*domain}",
|
||||
new { controller = "Caps", action = "Caps" },
|
||||
new { t = new TRouteConstraint("caps") });
|
||||
|
||||
app.MapControllerRoute(name: "movie-search",
|
||||
pattern: "{options}/{*domain}",
|
||||
defaults: new { controller = "Search", action = "MovieSearch" },
|
||||
constraints: new { t = new TRouteConstraint("movie") });
|
||||
app.MapControllerRoute("movie-search",
|
||||
"{options}/{*domain}",
|
||||
new { controller = "Search", action = "MovieSearch" },
|
||||
new { t = new TRouteConstraint("movie") });
|
||||
|
||||
app.MapControllerRoute(name: "tv-search",
|
||||
pattern: "{options}/{*domain}",
|
||||
defaults: new { controller = "Search", action = "TVSearch" },
|
||||
constraints: new { t = new TRouteConstraint("tvsearch") });
|
||||
app.MapControllerRoute("tv-search",
|
||||
"{options}/{*domain}",
|
||||
new { controller = "Search", action = "TVSearch" },
|
||||
new { t = new TRouteConstraint("tvsearch") });
|
||||
|
||||
app.MapControllerRoute(name: "music-search",
|
||||
pattern: "{options}/{*domain}",
|
||||
defaults: new { controller = "Search", action = "MusicSearch" },
|
||||
constraints: new { t = new TRouteConstraint("music") });
|
||||
app.MapControllerRoute("music-search",
|
||||
"{options}/{*domain}",
|
||||
new { controller = "Search", action = "MusicSearch" },
|
||||
new { t = new TRouteConstraint("music") });
|
||||
|
||||
app.MapControllerRoute(name: "book-search",
|
||||
pattern: "{options}/{*domain}",
|
||||
defaults: new { controller = "Search", action = "BookSearch" },
|
||||
constraints: new { t = new TRouteConstraint("book") });
|
||||
|
||||
app.MapControllerRoute(name: "generic-search",
|
||||
pattern: "{options}/{*domain}",
|
||||
defaults: new { controller = "Search", action = "GenericSearch" },
|
||||
constraints: new { t = new TRouteConstraint("search") });
|
||||
app.MapControllerRoute("book-search",
|
||||
"{options}/{*domain}",
|
||||
new { controller = "Search", action = "BookSearch" },
|
||||
new { t = new TRouteConstraint("book") });
|
||||
|
||||
app.MapControllerRoute("generic-search",
|
||||
"{options}/{*domain}",
|
||||
new { controller = "Search", action = "GenericSearch" },
|
||||
new { t = new TRouteConstraint("search") });
|
||||
app.Run();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user