|
|
@ -21,8 +21,6 @@ namespace MediaBrowser.Server.Mono
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private static ApplicationHost _appHost;
|
|
|
|
private static ApplicationHost _appHost;
|
|
|
|
|
|
|
|
|
|
|
|
private static Mutex _singleInstanceMutex;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static ILogger _logger;
|
|
|
|
private static ILogger _logger;
|
|
|
|
|
|
|
|
|
|
|
|
private static MainWindow _mainWindow;
|
|
|
|
private static MainWindow _mainWindow;
|
|
|
@ -45,18 +43,6 @@ namespace MediaBrowser.Server.Mono
|
|
|
|
|
|
|
|
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
|
|
|
|
|
|
|
|
|
|
|
bool createdNew;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//_singleInstanceMutex = new Mutex(true, @"Local\" + runningPath, out createdNew);
|
|
|
|
|
|
|
|
createdNew = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!createdNew)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_singleInstanceMutex = null;
|
|
|
|
|
|
|
|
logger.Info("Shutting down because another instance of Media Browser Server is already running.");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (PerformUpdateIfNeeded(appPaths, logger))
|
|
|
|
if (PerformUpdateIfNeeded(appPaths, logger))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logger.Info("Exiting to perform application update.");
|
|
|
|
logger.Info("Exiting to perform application update.");
|
|
|
@ -71,8 +57,6 @@ namespace MediaBrowser.Server.Mono
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logger.Info("Shutting down");
|
|
|
|
logger.Info("Shutting down");
|
|
|
|
|
|
|
|
|
|
|
|
ReleaseMutex(logger);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_appHost.Dispose();
|
|
|
|
_appHost.Dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -230,24 +214,6 @@ namespace MediaBrowser.Server.Mono
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// Releases the mutex.
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
internal static void ReleaseMutex(ILogger logger)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_singleInstanceMutex == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.Debug("Releasing mutex");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_singleInstanceMutex.ReleaseMutex();
|
|
|
|
|
|
|
|
_singleInstanceMutex.Close();
|
|
|
|
|
|
|
|
_singleInstanceMutex.Dispose();
|
|
|
|
|
|
|
|
_singleInstanceMutex = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the update if needed.
|
|
|
|
/// Performs the update if needed.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -278,24 +244,11 @@ namespace MediaBrowser.Server.Mono
|
|
|
|
|
|
|
|
|
|
|
|
public static void Restart()
|
|
|
|
public static void Restart()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Second instance will start first, so release the mutex and dispose the http server ahead of time
|
|
|
|
// Second instance will start first, so dispose so that the http ports will be available to the new instance
|
|
|
|
ReleaseMutex (_logger);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_appHost.Dispose();
|
|
|
|
_appHost.Dispose();
|
|
|
|
|
|
|
|
|
|
|
|
if (trayIcon != null) {
|
|
|
|
// Right now this method will just shutdown, but not restart
|
|
|
|
trayIcon.Visible = false;
|
|
|
|
Shutdown ();
|
|
|
|
trayIcon.Dispose ();
|
|
|
|
|
|
|
|
trayIcon = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_mainWindow != null) {
|
|
|
|
|
|
|
|
_mainWindow.HideAll ();
|
|
|
|
|
|
|
|
_mainWindow.Dispose ();
|
|
|
|
|
|
|
|
_mainWindow = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Application.Quit ();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|