mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Pls fix race condition
This commit is contained in:
parent
acac21d8dc
commit
032d72a8a7
@ -126,7 +126,6 @@ namespace Emby.Server.Implementations
|
|||||||
private IMediaEncoder _mediaEncoder;
|
private IMediaEncoder _mediaEncoder;
|
||||||
private ISessionManager _sessionManager;
|
private ISessionManager _sessionManager;
|
||||||
private string[] _urlPrefixes;
|
private string[] _urlPrefixes;
|
||||||
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this instance can self restart.
|
/// Gets a value indicating whether this instance can self restart.
|
||||||
@ -484,8 +483,9 @@ namespace Emby.Server.Implementations
|
|||||||
/// Runs the startup tasks.
|
/// Runs the startup tasks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><see cref="Task" />.</returns>
|
/// <returns><see cref="Task" />.</returns>
|
||||||
public async Task RunStartupTasksAsync()
|
public async Task RunStartupTasksAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
Logger.LogInformation("Running startup tasks");
|
Logger.LogInformation("Running startup tasks");
|
||||||
|
|
||||||
Resolve<ITaskManager>().AddTasks(GetExports<IScheduledTask>(false));
|
Resolve<ITaskManager>().AddTasks(GetExports<IScheduledTask>(false));
|
||||||
@ -501,13 +501,15 @@ namespace Emby.Server.Implementations
|
|||||||
|
|
||||||
var stopWatch = new Stopwatch();
|
var stopWatch = new Stopwatch();
|
||||||
stopWatch.Start();
|
stopWatch.Start();
|
||||||
await Task.WhenAll(StartEntryPoints(entryPoints, true)).ConfigureAwait(false);
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
await Task.WhenAny(Task.WhenAll(StartEntryPoints(entryPoints, true)), Task.Delay(-1, cancellationToken)).ConfigureAwait(false);
|
||||||
Logger.LogInformation("Executed all pre-startup entry points in {Elapsed:g}", stopWatch.Elapsed);
|
Logger.LogInformation("Executed all pre-startup entry points in {Elapsed:g}", stopWatch.Elapsed);
|
||||||
|
|
||||||
Logger.LogInformation("Core startup complete");
|
Logger.LogInformation("Core startup complete");
|
||||||
CoreStartupHasCompleted = true;
|
CoreStartupHasCompleted = true;
|
||||||
stopWatch.Restart();
|
stopWatch.Restart();
|
||||||
await Task.WhenAll(StartEntryPoints(entryPoints, false)).ConfigureAwait(false);
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
await Task.WhenAny(Task.WhenAll(StartEntryPoints(entryPoints, false)), Task.Delay(-1, cancellationToken)).ConfigureAwait(false);
|
||||||
Logger.LogInformation("Executed all post-startup entry points in {Elapsed:g}", stopWatch.Elapsed);
|
Logger.LogInformation("Executed all post-startup entry points in {Elapsed:g}", stopWatch.Elapsed);
|
||||||
stopWatch.Stop();
|
stopWatch.Stop();
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ namespace Jellyfin.Server
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
await appHost.RunStartupTasksAsync().ConfigureAwait(false);
|
await appHost.RunStartupTasksAsync(_tokenSource.Token).ConfigureAwait(false);
|
||||||
|
|
||||||
stopWatch.Stop();
|
stopWatch.Stop();
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
using Emby.Server.Implementations;
|
using Emby.Server.Implementations;
|
||||||
using Emby.Server.Implementations.IO;
|
using Emby.Server.Implementations.IO;
|
||||||
using Jellyfin.Server;
|
using Jellyfin.Server;
|
||||||
@ -21,7 +22,7 @@ namespace Jellyfin.Api.Tests
|
|||||||
public class JellyfinApplicationFactory : WebApplicationFactory<Startup>
|
public class JellyfinApplicationFactory : WebApplicationFactory<Startup>
|
||||||
{
|
{
|
||||||
private static readonly string _testPathRoot = Path.Combine(Path.GetTempPath(), "jellyfin-test-data");
|
private static readonly string _testPathRoot = Path.Combine(Path.GetTempPath(), "jellyfin-test-data");
|
||||||
private static readonly ConcurrentBag<IDisposable> _disposableComponents = new ConcurrentBag<IDisposable>();
|
private readonly ConcurrentBag<IDisposable> _disposableComponents = new ConcurrentBag<IDisposable>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="JellyfinApplicationFactory"/> class.
|
/// Initializes a new instance of the <see cref="JellyfinApplicationFactory"/> class.
|
||||||
@ -96,7 +97,7 @@ namespace Jellyfin.Api.Tests
|
|||||||
var appHost = (TestAppHost)testServer.Services.GetRequiredService<IApplicationHost>();
|
var appHost = (TestAppHost)testServer.Services.GetRequiredService<IApplicationHost>();
|
||||||
appHost.ServiceProvider = testServer.Services;
|
appHost.ServiceProvider = testServer.Services;
|
||||||
appHost.InitializeServices().GetAwaiter().GetResult();
|
appHost.InitializeServices().GetAwaiter().GetResult();
|
||||||
appHost.RunStartupTasksAsync().GetAwaiter().GetResult();
|
appHost.RunStartupTasksAsync(CancellationToken.None).GetAwaiter().GetResult();
|
||||||
|
|
||||||
return testServer;
|
return testServer;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user