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.Schedule.Jobs;
|
||||
using Ombi.Schedule.Jobs.Couchpotato;
|
||||
|
@ -12,7 +13,7 @@ using Ombi.Settings.Settings.Models;
|
|||
|
||||
namespace Ombi.Schedule
|
||||
{
|
||||
public class JobSetup : IJobSetup
|
||||
public class JobSetup : IJobSetup, IDisposable
|
||||
{
|
||||
public JobSetup(IPlexContentSync plexContentSync, IRadarrSync radarrSync,
|
||||
IOmbiAutomaticUpdater updater, IEmbyContentSync embySync, IPlexUserImporter userImporter,
|
||||
|
@ -65,5 +66,36 @@ namespace Ombi.Schedule
|
|||
RecurringJob.AddOrUpdate(() => _plexUserImporter.Start(), JobSettingsHelper.UserImporter(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.Dashboard;
|
||||
using Hangfire.SQLite;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
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.
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
|
||||
TelemetryConfiguration.Active.DisableTelemetry = true;
|
||||
// Add framework services.
|
||||
services.AddDbContext<OmbiContext>();
|
||||
|
||||
|
@ -183,12 +184,12 @@ namespace Ombi
|
|||
Authorization = new[] { new HangfireAuthorizationFilter() }
|
||||
});
|
||||
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 3 });
|
||||
|
||||
|
||||
// Setup the scheduler
|
||||
var jobSetup = app.ApplicationServices.GetService<IJobSetup>();
|
||||
jobSetup.Setup();
|
||||
ctx.Seed();
|
||||
|
||||
|
||||
var provider = new FileExtensionContentTypeProvider { Mappings = { [".map"] = "application/octet-stream" } };
|
||||
|
||||
app.UseStaticFiles(new StaticFileOptions()
|
||||
|
@ -218,6 +219,8 @@ namespace Ombi
|
|||
name: "spa-fallback",
|
||||
defaults: new { controller = "Home", action = "Index" });
|
||||
});
|
||||
|
||||
ombiService.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -168,6 +168,7 @@ namespace Ombi
|
|||
if (user == null)
|
||||
{
|
||||
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||
context.Response.RegisterForDispose(um);
|
||||
await context.Response.WriteAsync("Invalid User Access Token");
|
||||
}
|
||||
else
|
||||
|
@ -177,6 +178,7 @@ namespace Ombi
|
|||
var roles = await um.GetRolesAsync(user);
|
||||
var principal = new GenericPrincipal(identity, roles.ToArray());
|
||||
context.User = principal;
|
||||
context.Response.RegisterForDispose(um);
|
||||
await next();
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +191,7 @@ namespace Ombi
|
|||
if (!valid)
|
||||
{
|
||||
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||
context.Response.RegisterForDispose(settingsProvider);
|
||||
await context.Response.WriteAsync("Invalid API Key");
|
||||
}
|
||||
else
|
||||
|
@ -196,6 +199,7 @@ namespace Ombi
|
|||
var identity = new GenericIdentity("API");
|
||||
var principal = new GenericPrincipal(identity, new[] { "Admin", "ApiUser" });
|
||||
context.User = principal;
|
||||
context.Response.RegisterForDispose(settingsProvider);
|
||||
await next();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue