@ -110,7 +110,6 @@ using MediaBrowser.XbmcMetadata.Providers;
using Microsoft.Extensions.Logging ;
using Microsoft.Extensions.Logging ;
using ServiceStack ;
using ServiceStack ;
using ServiceStack.Text.Jsv ;
using ServiceStack.Text.Jsv ;
using StringExtensions = MediaBrowser . Controller . Extensions . StringExtensions ;
using X509Certificate = System . Security . Cryptography . X509Certificates . X509Certificate ;
using X509Certificate = System . Security . Cryptography . X509Certificates . X509Certificate ;
namespace Emby.Server.Implementations
namespace Emby.Server.Implementations
@ -302,7 +301,7 @@ namespace Emby.Server.Implementations
private ILiveTvManager LiveTvManager { get ; set ; }
private ILiveTvManager LiveTvManager { get ; set ; }
public I LocalizationManager LocalizationManager { get ; set ; }
public LocalizationManager LocalizationManager { get ; set ; }
private IEncodingManager EncodingManager { get ; set ; }
private IEncodingManager EncodingManager { get ; set ; }
private IChannelManager ChannelManager { get ; set ; }
private IChannelManager ChannelManager { get ; set ; }
@ -646,8 +645,10 @@ namespace Emby.Server.Implementations
/// <summary>
/// <summary>
/// Runs the startup tasks.
/// Runs the startup tasks.
/// </summary>
/// </summary>
public Task RunStartupTasks ( )
public async Task RunStartupTasks ( )
{
{
Logger . LogInformation ( "Running startup tasks" ) ;
Resolve < ITaskManager > ( ) . AddTasks ( GetExports < IScheduledTask > ( false ) ) ;
Resolve < ITaskManager > ( ) . AddTasks ( GetExports < IScheduledTask > ( false ) ) ;
ConfigurationManager . ConfigurationUpdated + = OnConfigurationUpdated ;
ConfigurationManager . ConfigurationUpdated + = OnConfigurationUpdated ;
@ -666,20 +667,20 @@ namespace Emby.Server.Implementations
Logger . LogInformation ( "ServerId: {0}" , SystemId ) ;
Logger . LogInformation ( "ServerId: {0}" , SystemId ) ;
var entryPoints = GetExports < IServerEntryPoint > ( ) ;
var entryPoints = GetExports < IServerEntryPoint > ( ) ;
RunEntryPoints ( entryPoints , true ) ;
var now = DateTime . UtcNow ;
await Task . WhenAll ( StartEntryPoints ( entryPoints , true ) ) ;
Logger . LogInformation ( "Executed all pre-startup entry points in {Elapsed:fff} ms" , DateTime . Now - now ) ;
Logger . LogInformation ( "Core startup complete" ) ;
Logger . LogInformation ( "Core startup complete" ) ;
HttpServer . GlobalResponse = null ;
HttpServer . GlobalResponse = null ;
Logger . LogInformation ( "Post-init migrations complete" ) ;
now = DateTime . UtcNow ;
await Task . WhenAll ( StartEntryPoints ( entryPoints , false ) ) ;
RunEntryPoints ( entryPoints , false ) ;
Logger . LogInformation ( "Executed all post-startup entry points in {Elapsed:fff} ms" , DateTime . Now - now ) ;
Logger . LogInformation ( "All entry points have started" ) ;
return Task . CompletedTask ;
}
}
private void Run EntryPoints( IEnumerable < IServerEntryPoint > entryPoints , bool isBeforeStartup )
private IEnumerable < Task > StartEntryPoints ( IEnumerable < IServerEntryPoint > entryPoints , bool isBeforeStartup )
{
{
foreach ( var entryPoint in entryPoints )
foreach ( var entryPoint in entryPoints )
{
{
@ -688,22 +689,13 @@ namespace Emby.Server.Implementations
continue ;
continue ;
}
}
var name = entryPoint . GetType ( ) . FullName ;
Logger . LogDebug ( "Starting entry point {Type}" , entryPoint . GetType ( ) ) ;
Logger . LogInformation ( "Starting entry point {Name}" , name ) ;
var now = DateTime . UtcNow ;
yield return entryPoint . RunAsync ( ) ;
try
{
entryPoint . Run ( ) ;
}
catch ( Exception ex )
{
Logger . LogError ( ex , "Error while running entrypoint {Name}" , name ) ;
}
Logger . LogInformation ( "Entry point completed: {Name}. Duration: {Duration} seconds" , name , ( DateTime . UtcNow - now ) . TotalSeconds . ToString ( CultureInfo . InvariantCulture ) , "ImageInfos" ) ;
}
}
}
}
public void Init ( )
public async Task Init ( )
{
{
HttpPort = ServerConfigurationManager . Configuration . HttpServerPortNumber ;
HttpPort = ServerConfigurationManager . Configuration . HttpServerPortNumber ;
HttpsPort = ServerConfigurationManager . Configuration . HttpsPortNumber ;
HttpsPort = ServerConfigurationManager . Configuration . HttpsPortNumber ;
@ -733,7 +725,7 @@ namespace Emby.Server.Implementations
SetHttpLimit ( ) ;
SetHttpLimit ( ) ;
RegisterResources ( ) ;
await RegisterResources ( ) ;
FindParts ( ) ;
FindParts ( ) ;
}
}
@ -748,7 +740,7 @@ namespace Emby.Server.Implementations
/// <summary>
/// <summary>
/// Registers resources that classes will depend on
/// Registers resources that classes will depend on
/// </summary>
/// </summary>
protected void RegisterResources ( )
protected async Task RegisterResources ( )
{
{
RegisterSingleInstance ( ConfigurationManager ) ;
RegisterSingleInstance ( ConfigurationManager ) ;
RegisterSingleInstance < IApplicationHost > ( this ) ;
RegisterSingleInstance < IApplicationHost > ( this ) ;
@ -809,9 +801,9 @@ namespace Emby.Server.Implementations
IAssemblyInfo assemblyInfo = new AssemblyInfo ( ) ;
IAssemblyInfo assemblyInfo = new AssemblyInfo ( ) ;
RegisterSingleInstance ( assemblyInfo ) ;
RegisterSingleInstance ( assemblyInfo ) ;
LocalizationManager = new LocalizationManager ( ServerConfigurationManager , FileSystemManager , JsonSerializer , LoggerFactory , assemblyInfo , new TextLocalizer ( ) );
LocalizationManager = new LocalizationManager ( ServerConfigurationManager , FileSystemManager , JsonSerializer , LoggerFactory );
StringExtensions . LocalizationManager = LocalizationManager ;
await LocalizationManager . LoadAll ( ) ;
RegisterSingleInstance (LocalizationManager ) ;
RegisterSingleInstance <ILocalizationManager > (LocalizationManager ) ;
BlurayExaminer = new BdInfoExaminer ( FileSystemManager ) ;
BlurayExaminer = new BdInfoExaminer ( FileSystemManager ) ;
RegisterSingleInstance ( BlurayExaminer ) ;
RegisterSingleInstance ( BlurayExaminer ) ;