fixed scheduled tasks firing too early
This commit is contained in:
parent
b1be6f1d73
commit
3acfd73d86
|
@ -13,7 +13,6 @@ using MediaBrowser.Common.Security;
|
||||||
using MediaBrowser.Common.Updates;
|
using MediaBrowser.Common.Updates;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using MediaBrowser.Model.System;
|
|
||||||
using MediaBrowser.Model.Updates;
|
using MediaBrowser.Model.Updates;
|
||||||
using SimpleInjector;
|
using SimpleInjector;
|
||||||
using System;
|
using System;
|
||||||
|
@ -26,6 +25,10 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Implementations
|
namespace MediaBrowser.Common.Implementations
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class BaseApplicationHost
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TApplicationPathsType">The type of the T application paths type.</typeparam>
|
||||||
public abstract class BaseApplicationHost<TApplicationPathsType> : IApplicationHost
|
public abstract class BaseApplicationHost<TApplicationPathsType> : IApplicationHost
|
||||||
where TApplicationPathsType : class, IApplicationPaths, new()
|
where TApplicationPathsType : class, IApplicationPaths, new()
|
||||||
{
|
{
|
||||||
|
@ -87,6 +90,7 @@ namespace MediaBrowser.Common.Implementations
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets assemblies that failed to load
|
/// Gets assemblies that failed to load
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <value>The failed assemblies.</value>
|
||||||
public List<string> FailedAssemblies { get; protected set; }
|
public List<string> FailedAssemblies { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -148,11 +152,31 @@ namespace MediaBrowser.Common.Implementations
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The kernel.</value>
|
/// <value>The kernel.</value>
|
||||||
protected ITaskManager TaskManager { get; private set; }
|
protected ITaskManager TaskManager { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the security manager.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The security manager.</value>
|
||||||
protected ISecurityManager SecurityManager { get; private set; }
|
protected ISecurityManager SecurityManager { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the package manager.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The package manager.</value>
|
||||||
protected IPackageManager PackageManager { get; private set; }
|
protected IPackageManager PackageManager { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the HTTP client.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The HTTP client.</value>
|
||||||
protected IHttpClient HttpClient { get; private set; }
|
protected IHttpClient HttpClient { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the network manager.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The network manager.</value>
|
||||||
protected INetworkManager NetworkManager { get; private set; }
|
protected INetworkManager NetworkManager { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the configuration manager.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The configuration manager.</value>
|
||||||
protected IConfigurationManager ConfigurationManager { get; private set; }
|
protected IConfigurationManager ConfigurationManager { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -187,7 +211,21 @@ namespace MediaBrowser.Common.Implementations
|
||||||
|
|
||||||
FindParts();
|
FindParts();
|
||||||
|
|
||||||
Task.Run(() => ConfigureAutoRunAtStartup());
|
await RunStartupTasks().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs the startup tasks.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
protected virtual Task RunStartupTasks()
|
||||||
|
{
|
||||||
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
Resolve<ITaskManager>().AddTasks(GetExports<IScheduledTask>(false));
|
||||||
|
|
||||||
|
Task.Run(() => ConfigureAutoRunAtStartup());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -202,6 +240,10 @@ namespace MediaBrowser.Common.Implementations
|
||||||
/// <value>The name of the log file prefix.</value>
|
/// <value>The name of the log file prefix.</value>
|
||||||
protected abstract string LogFilePrefixName { get; }
|
protected abstract string LogFilePrefixName { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the configuration manager.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>IConfigurationManager.</returns>
|
||||||
protected abstract IConfigurationManager GetConfigurationManager();
|
protected abstract IConfigurationManager GetConfigurationManager();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -210,8 +252,6 @@ namespace MediaBrowser.Common.Implementations
|
||||||
protected virtual void FindParts()
|
protected virtual void FindParts()
|
||||||
{
|
{
|
||||||
Plugins = GetExports<IPlugin>();
|
Plugins = GetExports<IPlugin>();
|
||||||
|
|
||||||
Resolve<ITaskManager>().AddTasks(GetExports<IScheduledTask>(false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -236,6 +276,7 @@ namespace MediaBrowser.Common.Implementations
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers resources that classes will depend on
|
/// Registers resources that classes will depend on
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
protected virtual Task RegisterResources()
|
protected virtual Task RegisterResources()
|
||||||
{
|
{
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
|
@ -509,10 +550,23 @@ namespace MediaBrowser.Common.Implementations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Restarts this instance.
|
||||||
|
/// </summary>
|
||||||
public abstract void Restart();
|
public abstract void Restart();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether this instance can self update.
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
|
||||||
public abstract bool CanSelfUpdate { get; }
|
public abstract bool CanSelfUpdate { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks for update.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <param name="progress">The progress.</param>
|
||||||
|
/// <returns>Task{CheckForUpdateResult}.</returns>
|
||||||
public abstract Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress);
|
public abstract Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -529,6 +583,9 @@ namespace MediaBrowser.Common.Implementations
|
||||||
EventHelper.QueueEventIfNotNull(ApplicationUpdated, this, new GenericEventArgs<Version> { Argument = package.version }, Logger);
|
EventHelper.QueueEventIfNotNull(ApplicationUpdated, this, new GenericEventArgs<Version> { Argument = package.version }, Logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shuts down.
|
||||||
|
/// </summary>
|
||||||
public abstract void Shutdown();
|
public abstract void Shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,10 @@ namespace MediaBrowser.Server.Implementations.Udp
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
_udpClient.Close();
|
if (_udpClient != null)
|
||||||
|
{
|
||||||
|
_udpClient.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -127,23 +127,21 @@ namespace MediaBrowser.ServerApplication
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The HTTP server.</value>
|
/// <value>The HTTP server.</value>
|
||||||
private IHttpServer HttpServer { get; set; }
|
private IHttpServer HttpServer { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Inits this instance.
|
/// Runs the startup tasks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
public override async Task Init()
|
protected override async Task RunStartupTasks()
|
||||||
{
|
{
|
||||||
await base.Init().ConfigureAwait(false);
|
// Do these before allowing the base method to run, which will invoke startup scheduled tasks
|
||||||
|
await ServerKernel.LoadRepositories(ServerConfigurationManager).ConfigureAwait(false);
|
||||||
|
|
||||||
Task.Run(async () =>
|
await base.RunStartupTasks().ConfigureAwait(false);
|
||||||
{
|
|
||||||
await ServerKernel.LoadRepositories(ServerConfigurationManager).ConfigureAwait(false);
|
|
||||||
|
|
||||||
DirectoryWatchers.Start();
|
DirectoryWatchers.Start();
|
||||||
|
|
||||||
Parallel.ForEach(GetExports<IServerEntryPoint>(), entryPoint => entryPoint.Run());
|
Parallel.ForEach(GetExports<IServerEntryPoint>(), entryPoint => entryPoint.Run());
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -206,13 +204,15 @@ namespace MediaBrowser.ServerApplication
|
||||||
ServerKernel.FFMpegManager = new FFMpegManager(ServerKernel, ZipClient, JsonSerializer, ProtobufSerializer, LogManager, ApplicationPaths);
|
ServerKernel.FFMpegManager = new FFMpegManager(ServerKernel, ZipClient, JsonSerializer, ProtobufSerializer, LogManager, ApplicationPaths);
|
||||||
ServerKernel.ImageManager = new ImageManager(ServerKernel, ProtobufSerializer, LogManager.GetLogger("ImageManager"), ApplicationPaths);
|
ServerKernel.ImageManager = new ImageManager(ServerKernel, ProtobufSerializer, LogManager.GetLogger("ImageManager"), ApplicationPaths);
|
||||||
|
|
||||||
ServerKernel.UserDataRepositories = GetExports<IUserDataRepository>();
|
Parallel.Invoke(
|
||||||
ServerKernel.UserRepositories = GetExports<IUserRepository>();
|
() => ServerKernel.UserDataRepositories = GetExports<IUserDataRepository>(),
|
||||||
ServerKernel.DisplayPreferencesRepositories = GetExports<IDisplayPreferencesRepository>();
|
() => ServerKernel.UserRepositories = GetExports<IUserRepository>(),
|
||||||
ServerKernel.ItemRepositories = GetExports<IItemRepository>();
|
() => ServerKernel.DisplayPreferencesRepositories = GetExports<IDisplayPreferencesRepository>(),
|
||||||
ServerKernel.WeatherProviders = GetExports<IWeatherProvider>();
|
() => ServerKernel.ItemRepositories = GetExports<IItemRepository>(),
|
||||||
ServerKernel.ImageEnhancers = GetExports<IImageEnhancer>().OrderBy(e => e.Priority).ToArray();
|
() => ServerKernel.WeatherProviders = GetExports<IWeatherProvider>(),
|
||||||
ServerKernel.StringFiles = GetExports<LocalizedStringData>();
|
() => ServerKernel.ImageEnhancers = GetExports<IImageEnhancer>().OrderBy(e => e.Priority).ToArray(),
|
||||||
|
() => ServerKernel.StringFiles = GetExports<LocalizedStringData>()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -238,14 +238,20 @@ namespace MediaBrowser.ServerApplication
|
||||||
{
|
{
|
||||||
base.FindParts();
|
base.FindParts();
|
||||||
|
|
||||||
HttpServer.Init(GetExports<IRestfulService>(false));
|
Parallel.Invoke(
|
||||||
|
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
HttpServer.Init(GetExports<IRestfulService>(false));
|
||||||
|
|
||||||
ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false));
|
ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false));
|
||||||
ServerManager.Start();
|
ServerManager.Start();
|
||||||
|
},
|
||||||
|
|
||||||
LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(), GetExports<IVirtualFolderCreator>(), GetExports<IItemResolver>(), GetExports<IIntroProvider>(), GetExports<IBaseItemComparer>());
|
() => LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(), GetExports<IVirtualFolderCreator>(), GetExports<IItemResolver>(), GetExports<IIntroProvider>(), GetExports<IBaseItemComparer>()),
|
||||||
|
|
||||||
ProviderManager.AddMetadataProviders(GetExports<BaseMetadataProvider>().OrderBy(e => e.Priority).ToArray());
|
() => ProviderManager.AddMetadataProviders(GetExports<BaseMetadataProvider>().OrderBy(e => e.Priority).ToArray())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user