Files
SPT-Server-Build/SPTarkov.Server/Services/SptServerBackgroundService.cs
T
Jesse fc7660b6c8 Slight bundle & fileutil refactor: (#524)
- Actually load the bundle cache file now
- Don't read file as string with StreamReader, instead read with ReadAllTextAsync
- Slight refactor to bundle hashing

Co-authored-by: Chomp <27521899+chompDev@users.noreply.github.com>
2025-07-30 22:23:29 +00:00

30 lines
965 B
C#

using System.Runtime;
using SPTarkov.Server.Core.Loaders;
using SPTarkov.Server.Core.Models.Spt.Mod;
using SPTarkov.Server.Core.Utils;
namespace SPTarkov.Server.Services;
public class SptServerBackgroundService(IReadOnlyList<SptMod> loadedMods, BundleLoader bundleLoader, App app) : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
if (ProgramStatics.MODS())
{
foreach (var mod in loadedMods)
{
if (mod.ModMetadata.IsBundleMod == true)
{
await bundleLoader.LoadBundlesAsync(mod);
}
}
}
await app.InitializeAsync();
// Run garbage collection now the server is ready to start
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive, true, true);
}
}