added CanSelfRestart

This commit is contained in:
Luke Pulverenti 2013-10-07 10:38:31 -04:00
parent 3f1cafdc81
commit 65f78ea5ad
9 changed files with 70 additions and 10 deletions

View file

@ -590,6 +590,12 @@ namespace MediaBrowser.Common.Implementations
Plugins = list; Plugins = list;
} }
/// <summary>
/// Gets a value indicating whether this instance can self restart.
/// </summary>
/// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
public abstract bool CanSelfRestart { get; }
/// <summary> /// <summary>
/// Notifies that the kernel that a change has been made that requires a restart /// Notifies that the kernel that a change has been made that requires a restart
/// </summary> /// </summary>

View file

@ -24,6 +24,12 @@ namespace MediaBrowser.Common
/// <value><c>true</c> if this instance has pending kernel reload; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance has pending kernel reload; otherwise, <c>false</c>.</value>
bool HasPendingRestart { get; } bool HasPendingRestart { get; }
/// <summary>
/// Gets a value indicating whether this instance can self restart.
/// </summary>
/// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
bool CanSelfRestart { get; }
/// <summary> /// <summary>
/// Occurs when [has pending restart changed]. /// Occurs when [has pending restart changed].
/// </summary> /// </summary>

View file

@ -62,6 +62,12 @@ namespace MediaBrowser.Model.System
/// <value><c>true</c> if [supports native web socket]; otherwise, <c>false</c>.</value> /// <value><c>true</c> if [supports native web socket]; otherwise, <c>false</c>.</value>
public bool SupportsNativeWebSocket { get; set; } public bool SupportsNativeWebSocket { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance can self restart.
/// </summary>
/// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
public bool CanSelfRestart { get; set; }
/// <summary> /// <summary>
/// Gets or sets plugin assemblies that failed to load. /// Gets or sets plugin assemblies that failed to load.
/// </summary> /// </summary>

View file

@ -180,6 +180,15 @@ namespace MediaBrowser.ServerApplication
} }
/// <summary>
/// Gets a value indicating whether this instance can self restart.
/// </summary>
/// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
public override bool CanSelfRestart
{
get { return NativeApp.CanSelfRestart; }
}
/// <summary> /// <summary>
/// Runs the startup tasks. /// Runs the startup tasks.
/// </summary> /// </summary>
@ -384,7 +393,7 @@ namespace MediaBrowser.ServerApplication
await repo.Initialize().ConfigureAwait(false); await repo.Initialize().ConfigureAwait(false);
((UserDataManager) UserDataManager).Repository = repo; ((UserDataManager)UserDataManager).Repository = repo;
} }
/// <summary> /// <summary>
@ -493,6 +502,11 @@ namespace MediaBrowser.ServerApplication
/// </summary> /// </summary>
public override async Task Restart() public override async Task Restart()
{ {
if (!CanSelfRestart)
{
throw new InvalidOperationException("The server is unable to self-restart. Please restart manually.");
}
try try
{ {
await SessionManager.SendServerRestartNotification(CancellationToken.None).ConfigureAwait(false); await SessionManager.SendServerRestartNotification(CancellationToken.None).ConfigureAwait(false);
@ -588,7 +602,8 @@ namespace MediaBrowser.ServerApplication
ProgramDataPath = ApplicationPaths.ProgramDataPath, ProgramDataPath = ApplicationPaths.ProgramDataPath,
MacAddress = GetMacAddress(), MacAddress = GetMacAddress(),
HttpServerPortNumber = ServerConfigurationManager.Configuration.HttpServerPortNumber, HttpServerPortNumber = ServerConfigurationManager.Configuration.HttpServerPortNumber,
OperatingSystem = Environment.OSVersion.ToString() OperatingSystem = Environment.OSVersion.ToString(),
CanSelfRestart = CanSelfRestart
}; };
} }

View file

@ -1,4 +1,5 @@
using MediaBrowser.Common.Constants; using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Constants;
using MediaBrowser.Common.Implementations.Logging; using MediaBrowser.Common.Implementations.Logging;
using MediaBrowser.Common.Implementations.Updates; using MediaBrowser.Common.Implementations.Updates;
using MediaBrowser.Controller.IO; using MediaBrowser.Controller.IO;
@ -44,7 +45,7 @@ namespace MediaBrowser.ServerApplication
var logger = _logger = logManager.GetLogger("Main"); var logger = _logger = logManager.GetLogger("Main");
BeginLog(logger); BeginLog(logger, appPaths);
// Install directly // Install directly
if (string.Equals(startFlag, "-installservice", StringComparison.OrdinalIgnoreCase)) if (string.Equals(startFlag, "-installservice", StringComparison.OrdinalIgnoreCase))
@ -162,17 +163,31 @@ namespace MediaBrowser.ServerApplication
return new ServerApplicationPaths(); return new ServerApplicationPaths();
} }
/// <summary>
/// Gets a value indicating whether this instance can self restart.
/// </summary>
/// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
public static bool CanSelfRestart
{
get
{
return true;
}
}
/// <summary> /// <summary>
/// Begins the log. /// Begins the log.
/// </summary> /// </summary>
/// <param name="logger">The logger.</param> /// <param name="logger">The logger.</param>
private static void BeginLog(ILogger logger) /// <param name="appPaths">The app paths.</param>
private static void BeginLog(ILogger logger, IApplicationPaths appPaths)
{ {
logger.Info("Media Browser Server started"); logger.Info("Media Browser Server started");
logger.Info("Command line: {0}", string.Join(" ", Environment.GetCommandLineArgs())); logger.Info("Command line: {0}", string.Join(" ", Environment.GetCommandLineArgs()));
logger.Info("Server: {0}", Environment.MachineName); logger.Info("Server: {0}", Environment.MachineName);
logger.Info("Operating system: {0}", Environment.OSVersion.ToString()); logger.Info("Operating system: {0}", Environment.OSVersion.ToString());
logger.Info("Program data path: {0}", appPaths.ProgramDataPath);
} }
/// <summary> /// <summary>

View file

@ -21,5 +21,17 @@ namespace MediaBrowser.ServerApplication.Native
{ {
MainStartup.Restart(); MainStartup.Restart();
} }
/// <summary>
/// Determines whether this instance [can self restart].
/// </summary>
/// <returns><c>true</c> if this instance [can self restart]; otherwise, <c>false</c>.</returns>
public static bool CanSelfRestart
{
get
{
return MainStartup.CanSelfRestart;
}
}
} }
} }

View file

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common.Internal</id> <id>MediaBrowser.Common.Internal</id>
<version>3.0.222</version> <version>3.0.223</version>
<title>MediaBrowser.Common.Internal</title> <title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors> <authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description> <description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.222" /> <dependency id="MediaBrowser.Common" version="3.0.223" />
<dependency id="NLog" version="2.0.1.2" /> <dependency id="NLog" version="2.0.1.2" />
<dependency id="ServiceStack.Text" version="3.9.58" /> <dependency id="ServiceStack.Text" version="3.9.58" />
<dependency id="SimpleInjector" version="2.3.2" /> <dependency id="SimpleInjector" version="2.3.2" />

View file

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common</id> <id>MediaBrowser.Common</id>
<version>3.0.222</version> <version>3.0.223</version>
<title>MediaBrowser.Common</title> <title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>

View file

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Server.Core</id> <id>MediaBrowser.Server.Core</id>
<version>3.0.222</version> <version>3.0.223</version>
<title>Media Browser.Server.Core</title> <title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description> <description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.222" /> <dependency id="MediaBrowser.Common" version="3.0.223" />
</dependencies> </dependencies>
</metadata> </metadata>
<files> <files>