mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 05:13:18 -07:00
Memory improvements
This commit is contained in:
parent
9428c66825
commit
daaf52d771
3 changed files with 44 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
||||||
using Hangfire;
|
using System;
|
||||||
|
using Hangfire;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
using Ombi.Schedule.Jobs;
|
using Ombi.Schedule.Jobs;
|
||||||
using Ombi.Schedule.Jobs.Couchpotato;
|
using Ombi.Schedule.Jobs.Couchpotato;
|
||||||
|
@ -12,7 +13,7 @@ using Ombi.Settings.Settings.Models;
|
||||||
|
|
||||||
namespace Ombi.Schedule
|
namespace Ombi.Schedule
|
||||||
{
|
{
|
||||||
public class JobSetup : IJobSetup
|
public class JobSetup : IJobSetup, IDisposable
|
||||||
{
|
{
|
||||||
public JobSetup(IPlexContentSync plexContentSync, IRadarrSync radarrSync,
|
public JobSetup(IPlexContentSync plexContentSync, IRadarrSync radarrSync,
|
||||||
IOmbiAutomaticUpdater updater, IEmbyContentSync embySync, IPlexUserImporter userImporter,
|
IOmbiAutomaticUpdater updater, IEmbyContentSync embySync, IPlexUserImporter userImporter,
|
||||||
|
@ -65,5 +66,36 @@ namespace Ombi.Schedule
|
||||||
RecurringJob.AddOrUpdate(() => _plexUserImporter.Start(), JobSettingsHelper.UserImporter(s));
|
RecurringJob.AddOrUpdate(() => _plexUserImporter.Start(), JobSettingsHelper.UserImporter(s));
|
||||||
RecurringJob.AddOrUpdate(() => _newsletter.Start(), JobSettingsHelper.Newsletter(s));
|
RecurringJob.AddOrUpdate(() => _newsletter.Start(), JobSettingsHelper.Newsletter(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool _disposed;
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (_disposed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
_plexContentSync?.Dispose();
|
||||||
|
_radarrSync?.Dispose();
|
||||||
|
_updater?.Dispose();
|
||||||
|
_plexUserImporter?.Dispose();
|
||||||
|
_embyContentSync?.Dispose();
|
||||||
|
_embyUserImporter?.Dispose();
|
||||||
|
_sonarrSync?.Dispose();
|
||||||
|
_cpCache?.Dispose();
|
||||||
|
_srSync?.Dispose();
|
||||||
|
_jobSettings?.Dispose();
|
||||||
|
_refreshMetadata?.Dispose();
|
||||||
|
_newsletter?.Dispose();
|
||||||
|
}
|
||||||
|
_disposed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ using Hangfire;
|
||||||
using Hangfire.Console;
|
using Hangfire.Console;
|
||||||
using Hangfire.Dashboard;
|
using Hangfire.Dashboard;
|
||||||
using Hangfire.SQLite;
|
using Hangfire.SQLite;
|
||||||
|
using Microsoft.ApplicationInsights.Extensibility;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
@ -85,7 +86,7 @@ namespace Ombi
|
||||||
// This method gets called by the runtime. Use this method to add services to the container.
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
TelemetryConfiguration.Active.DisableTelemetry = true;
|
||||||
// Add framework services.
|
// Add framework services.
|
||||||
services.AddDbContext<OmbiContext>();
|
services.AddDbContext<OmbiContext>();
|
||||||
|
|
||||||
|
@ -183,12 +184,12 @@ namespace Ombi
|
||||||
Authorization = new[] { new HangfireAuthorizationFilter() }
|
Authorization = new[] { new HangfireAuthorizationFilter() }
|
||||||
});
|
});
|
||||||
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 3 });
|
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 3 });
|
||||||
|
|
||||||
// Setup the scheduler
|
// Setup the scheduler
|
||||||
var jobSetup = app.ApplicationServices.GetService<IJobSetup>();
|
var jobSetup = app.ApplicationServices.GetService<IJobSetup>();
|
||||||
jobSetup.Setup();
|
jobSetup.Setup();
|
||||||
ctx.Seed();
|
ctx.Seed();
|
||||||
|
|
||||||
var provider = new FileExtensionContentTypeProvider { Mappings = { [".map"] = "application/octet-stream" } };
|
var provider = new FileExtensionContentTypeProvider { Mappings = { [".map"] = "application/octet-stream" } };
|
||||||
|
|
||||||
app.UseStaticFiles(new StaticFileOptions()
|
app.UseStaticFiles(new StaticFileOptions()
|
||||||
|
@ -218,6 +219,8 @@ namespace Ombi
|
||||||
name: "spa-fallback",
|
name: "spa-fallback",
|
||||||
defaults: new { controller = "Home", action = "Index" });
|
defaults: new { controller = "Home", action = "Index" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ombiService.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,6 +168,7 @@ namespace Ombi
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||||
|
context.Response.RegisterForDispose(um);
|
||||||
await context.Response.WriteAsync("Invalid User Access Token");
|
await context.Response.WriteAsync("Invalid User Access Token");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -177,6 +178,7 @@ namespace Ombi
|
||||||
var roles = await um.GetRolesAsync(user);
|
var roles = await um.GetRolesAsync(user);
|
||||||
var principal = new GenericPrincipal(identity, roles.ToArray());
|
var principal = new GenericPrincipal(identity, roles.ToArray());
|
||||||
context.User = principal;
|
context.User = principal;
|
||||||
|
context.Response.RegisterForDispose(um);
|
||||||
await next();
|
await next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,6 +191,7 @@ namespace Ombi
|
||||||
if (!valid)
|
if (!valid)
|
||||||
{
|
{
|
||||||
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||||
|
context.Response.RegisterForDispose(settingsProvider);
|
||||||
await context.Response.WriteAsync("Invalid API Key");
|
await context.Response.WriteAsync("Invalid API Key");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -196,6 +199,7 @@ namespace Ombi
|
||||||
var identity = new GenericIdentity("API");
|
var identity = new GenericIdentity("API");
|
||||||
var principal = new GenericPrincipal(identity, new[] { "Admin", "ApiUser" });
|
var principal = new GenericPrincipal(identity, new[] { "Admin", "ApiUser" });
|
||||||
context.User = principal;
|
context.User = principal;
|
||||||
|
context.Response.RegisterForDispose(settingsProvider);
|
||||||
await next();
|
await next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue