22ab053cda
* Reordered services startup * Removed unnecessary comment * Made startup service required * Marked other services as required * Removed unnecessary ! for null --------- Co-authored-by: Alex <clodanSPT@hotmail.com> Co-authored-by: Chomp <27521899+chompDev@users.noreply.github.com>
32 lines
963 B
C#
32 lines
963 B
C#
using System.Runtime;
|
|
using SPTarkov.DI.Annotations;
|
|
using SPTarkov.Server.Core.Loaders;
|
|
using SPTarkov.Server.Core.Models.Spt.Mod;
|
|
using SPTarkov.Server.Core.Utils;
|
|
|
|
namespace SPTarkov.Server.Services;
|
|
|
|
[Injectable(InjectionType.Singleton)]
|
|
public class SptServerStartupService(IReadOnlyList<SptMod> loadedMods, BundleLoader bundleLoader, App app)
|
|
{
|
|
public async Task Startup()
|
|
{
|
|
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);
|
|
}
|
|
}
|