aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-06 20:49:33 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-06 20:49:33 -0400
commit3f1cafdc814c6d0ef866f1c68dcb4dd1034099ec (patch)
treec16390ad4e6f2b5ca1406ab1f77a9a5cf364869f /MediaBrowser.ServerApplication
parentbd5bf32aba45f3a4dff4f883505ddf9fb528e53a (diff)
updated nuget
Diffstat (limited to 'MediaBrowser.ServerApplication')
-rw-r--r--MediaBrowser.ServerApplication/MainStartup.cs36
1 files changed, 9 insertions, 27 deletions
diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs
index 577f5ea38..e69d46661 100644
--- a/MediaBrowser.ServerApplication/MainStartup.cs
+++ b/MediaBrowser.ServerApplication/MainStartup.cs
@@ -26,8 +26,6 @@ namespace MediaBrowser.ServerApplication
private static ILogger _logger;
- private static bool _isRestarting = false;
-
private static bool _isRunningAsService = false;
/// <summary>
@@ -132,7 +130,7 @@ namespace MediaBrowser.ServerApplication
if (duplicate != null)
{
_logger.Info("Found a duplicate process. Giving it time to exit.");
-
+
if (!duplicate.WaitForExit(5000))
{
_logger.Info("The duplicate process did not exit.");
@@ -204,7 +202,7 @@ namespace MediaBrowser.ServerApplication
SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT |
ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX);
}
-
+
_app.Run();
}
@@ -249,13 +247,6 @@ namespace MediaBrowser.ServerApplication
SetErrorMode(ErrorModes.SYSTEM_DEFAULT);
}
- if (_isRestarting)
- {
- Process.Start("cmd", "/c net start " + BackgroundService.Name);
-
- _logger.Info("New service process started");
- }
-
_app.Dispatcher.Invoke(_app.Shutdown);
}
@@ -270,6 +261,11 @@ namespace MediaBrowser.ServerApplication
{
ManagedInstallerClass.InstallHelper(new[] { runningPath });
+ using (var process = Process.Start("cmd.exe", "/c sc failure " + BackgroundService.Name + " reset= 0 actions= restart/1000/restart/1000/restart/60000"))
+ {
+ process.WaitForExit();
+ }
+
logger.Info("Service installation succeeded");
}
catch (Exception ex)
@@ -445,15 +441,6 @@ namespace MediaBrowser.ServerApplication
_logger.Info("Disposing app host");
_appHost.Dispose();
- _logger.Info("Starting new instance of server");
- RestartInternal();
-
- _logger.Info("Shutting down existing instance of server.");
- Shutdown();
- }
-
- private static void RestartInternal()
- {
if (!_isRunningAsService)
{
_logger.Info("Starting server application");
@@ -461,8 +448,8 @@ namespace MediaBrowser.ServerApplication
}
else
{
- _logger.Info("Starting windows service");
- RestartWindowsService();
+ _logger.Info("Calling Enviornment.Exit to tell Windows to restart the server.");
+ Environment.Exit(1);
}
}
@@ -471,11 +458,6 @@ namespace MediaBrowser.ServerApplication
System.Windows.Forms.Application.Restart();
}
- private static void RestartWindowsService()
- {
- _isRestarting = true;
- }
-
private static void ShutdownWindowsApplication()
{
_app.Dispatcher.Invoke(_app.Shutdown);