diff --git a/MediaBrowser.Server.Mac/Main.cs b/MediaBrowser.Server.Mac/Main.cs
index b4184f3b19..cffa62fae7 100644
--- a/MediaBrowser.Server.Mac/Main.cs
+++ b/MediaBrowser.Server.Mac/Main.cs
@@ -146,6 +146,26 @@ namespace MediaBrowser.Server.Mac
MenuBarIcon.Instance.Terminate ();
}
+ public static void Restart()
+ {
+ _logger.Info("Disposing app host");
+ AppHost.Dispose();
+
+ _logger.Info("Starting new instance");
+
+ var currentProcess = Process.GetCurrentProcess();
+
+ var args = Environment.GetCommandLineArgs()
+ .Select(NormalizeCommandLineArgument);
+
+ var commandLineArgsString = string.Join(" ", args.ToArray());
+
+ Process.Start(currentProcess.MainModule.FileName, commandLineArgsString);
+
+ _logger.Info("AppController.Terminate");
+ MenuBarIcon.Instance.Terminate();
+ }
+
///
/// Handles the UnhandledException event of the CurrentDomain control.
///
diff --git a/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs
index 9821f49ddd..57610dfc2c 100644
--- a/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs
+++ b/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs
@@ -19,16 +19,16 @@ namespace MediaBrowser.Server.Mac
///
/// Restarts this instance.
///
- public void Restart()
+ public virtual void Restart()
{
-
+ throw new NotImplementedException();
}
///
/// Determines whether this instance [can self restart].
///
/// true if this instance [can self restart]; otherwise, false.
- public bool CanSelfRestart
+ public virtual bool CanSelfRestart
{
get
{
diff --git a/MediaBrowser.Server.Mac/Native/NativeApp.cs b/MediaBrowser.Server.Mac/Native/NativeApp.cs
index f7c2dd4c95..4515be0517 100644
--- a/MediaBrowser.Server.Mac/Native/NativeApp.cs
+++ b/MediaBrowser.Server.Mac/Native/NativeApp.cs
@@ -13,7 +13,27 @@ namespace MediaBrowser.Server.Mac
public override void Shutdown()
{
MainClass.Shutdown();
- }
+ }
+
+ ///
+ /// Determines whether this instance [can self restart].
+ ///
+ /// true if this instance can self restart; otherwise, false.
+ public override bool CanSelfRestart
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ ///
+ /// Restarts this instance.
+ ///
+ public override void Restart()
+ {
+ MainClass.Restart();
+ }
}
}
diff --git a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs
index aea6d73679..ba96ca737b 100644
--- a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs
+++ b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs
@@ -21,16 +21,16 @@ namespace MediaBrowser.Server.Mono.Native
///
/// Restarts this instance.
///
- public void Restart()
+ public virtual void Restart()
{
-
+ throw new NotImplementedException();
}
///
/// Determines whether this instance [can self restart].
///
/// true if this instance [can self restart]; otherwise, false.
- public bool CanSelfRestart
+ public virtual bool CanSelfRestart
{
get
{
diff --git a/MediaBrowser.Server.Mono/Native/NativeApp.cs b/MediaBrowser.Server.Mono/Native/NativeApp.cs
index d92b86157a..8c954ffcc5 100644
--- a/MediaBrowser.Server.Mono/Native/NativeApp.cs
+++ b/MediaBrowser.Server.Mono/Native/NativeApp.cs
@@ -13,5 +13,25 @@ namespace MediaBrowser.Server.Mono.Native
{
MainClass.Shutdown();
}
+
+ ///
+ /// Determines whether this instance [can self restart].
+ ///
+ /// true if this instance can self restart; otherwise, false.
+ public override bool CanSelfRestart
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ ///
+ /// Restarts this instance.
+ ///
+ public override void Restart()
+ {
+ MainClass.Restart();
+ }
}
}
diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs
index 10a6c6fb91..7cd80f5c97 100644
--- a/MediaBrowser.Server.Mono/Program.cs
+++ b/MediaBrowser.Server.Mono/Program.cs
@@ -1,4 +1,3 @@
-using System.IO;
using MediaBrowser.Common.Implementations.IO;
using MediaBrowser.Common.Implementations.Logging;
using MediaBrowser.Model.Logging;
@@ -8,6 +7,8 @@ using MediaBrowser.Server.Startup.Common;
using Microsoft.Win32;
using System;
using System.Diagnostics;
+using System.IO;
+using System.Linq;
using System.Net;
using System.Net.Security;
using System.Reflection;
@@ -136,6 +137,36 @@ namespace MediaBrowser.Server.Mono
{
ApplicationTaskCompletionSource.SetResult (true);
}
+
+ public static void Restart()
+ {
+ _logger.Info("Disposing app host");
+ _appHost.Dispose();
+
+ _logger.Info("Starting new instance");
+
+ var currentProcess = Process.GetCurrentProcess();
+
+ var args = Environment.GetCommandLineArgs()
+ .Select(NormalizeCommandLineArgument);
+
+ var commandLineArgsString = string.Join(" ", args.ToArray());
+
+ Process.Start(currentProcess.MainModule.FileName, commandLineArgsString);
+
+ _logger.Info("Calling Environment.Exit");
+ Environment.Exit(0);
+ }
+
+ private static string NormalizeCommandLineArgument(string arg)
+ {
+ if (arg.IndexOf(" ", StringComparison.OrdinalIgnoreCase) == -1)
+ {
+ return arg;
+ }
+
+ return "\"" + arg + "\"";
+ }
}
class NoCheckCertificatePolicy : ICertificatePolicy
diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs
index f918fc37cc..968172bc3a 100644
--- a/MediaBrowser.ServerApplication/MainStartup.cs
+++ b/MediaBrowser.ServerApplication/MainStartup.cs
@@ -516,11 +516,11 @@ namespace MediaBrowser.ServerApplication
_logger.Info("Hiding server notify icon");
_serverNotifyIcon.Visible = false;
- _logger.Info("Executing windows forms restart");
+ _logger.Info("Starting new instance");
//Application.Restart();
Process.Start(_appHost.ServerConfigurationManager.ApplicationPaths.ApplicationPath);
- _logger.Info("Calling Application.Exit");
+ _logger.Info("Calling Environment.Exit");
Environment.Exit(0);
}
}
diff --git a/SharedVersion.cs b/SharedVersion.cs
index 5da02ac703..653297d702 100644
--- a/SharedVersion.cs
+++ b/SharedVersion.cs
@@ -1,4 +1,4 @@
using System.Reflection;
//[assembly: AssemblyVersion("3.0.*")]
-[assembly: AssemblyVersion("3.0.5621.0")]
+[assembly: AssemblyVersion("3.0.5621.1")]