aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-07 12:22:19 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-07 12:22:19 -0400
commit4a030a70a95a51af22f8915801f28614d638714e (patch)
tree18451543f49dd642211fa604404d55dac76e7a1f /MediaBrowser.ServerApplication
parent65f78ea5ad19620d73eba54ac289fb78ef70af2b (diff)
remove self update capability from service
Diffstat (limited to 'MediaBrowser.ServerApplication')
-rw-r--r--MediaBrowser.ServerApplication/ApplicationHost.cs5
-rw-r--r--MediaBrowser.ServerApplication/MainStartup.cs42
-rw-r--r--MediaBrowser.ServerApplication/Native/NativeApp.cs12
3 files changed, 36 insertions, 23 deletions
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index b74fd8a739..ed9179b076 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -530,7 +530,7 @@ namespace MediaBrowser.ServerApplication
#if DEBUG
return false;
#endif
- return true;
+ return NativeApp.CanSelfUpdate;
}
}
@@ -603,7 +603,8 @@ namespace MediaBrowser.ServerApplication
MacAddress = GetMacAddress(),
HttpServerPortNumber = ServerConfigurationManager.Configuration.HttpServerPortNumber,
OperatingSystem = Environment.OSVersion.ToString(),
- CanSelfRestart = CanSelfRestart
+ CanSelfRestart = CanSelfRestart,
+ CanSelfUpdate = CanSelfUpdate
};
}
diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs
index b4b2cf1071..f61b0f1d13 100644
--- a/MediaBrowser.ServerApplication/MainStartup.cs
+++ b/MediaBrowser.ServerApplication/MainStartup.cs
@@ -114,7 +114,7 @@ namespace MediaBrowser.ServerApplication
/// <returns><c>true</c> if [is already running] [the specified current process]; otherwise, <c>false</c>.</returns>
private static bool IsAlreadyRunning(Process currentProcess)
{
- var runningPath = Process.GetCurrentProcess().MainModule.FileName;
+ var runningPath = currentProcess.MainModule.FileName;
var duplicate = Process.GetProcesses().FirstOrDefault(i =>
{
@@ -151,13 +151,11 @@ namespace MediaBrowser.ServerApplication
{
if (runAsService)
{
-#if (RELEASE)
var systemPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
var programDataPath = Path.GetDirectoryName(systemPath);
return new ServerApplicationPaths(programDataPath);
-#endif
}
return new ServerApplicationPaths();
@@ -171,7 +169,19 @@ namespace MediaBrowser.ServerApplication
{
get
{
- return true;
+ return !_isRunningAsService;
+ }
+ }
+
+ /// <summary>
+ /// Gets 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 static bool CanSelfUpdate
+ {
+ get
+ {
+ return !_isRunningAsService;
}
}
@@ -188,6 +198,9 @@ namespace MediaBrowser.ServerApplication
logger.Info("Server: {0}", Environment.MachineName);
logger.Info("Operating system: {0}", Environment.OSVersion.ToString());
logger.Info("Program data path: {0}", appPaths.ProgramDataPath);
+
+ var runningPath = Process.GetCurrentProcess().MainModule.FileName;
+ logger.Info("Executable: {0}", runningPath);
}
/// <summary>
@@ -276,11 +289,6 @@ 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)
@@ -458,19 +466,11 @@ namespace MediaBrowser.ServerApplication
if (!_isRunningAsService)
{
- _logger.Info("Starting server application");
- RestartWindowsApplication();
- }
- else
- {
- _logger.Info("Calling Enviornment.Exit to tell Windows to restart the server.");
- Environment.Exit(1);
- }
- }
+ _logger.Info("Executing windows forms restart");
+ System.Windows.Forms.Application.Restart();
- private static void RestartWindowsApplication()
- {
- System.Windows.Forms.Application.Restart();
+ ShutdownWindowsApplication();
+ }
}
private static void ShutdownWindowsApplication()
diff --git a/MediaBrowser.ServerApplication/Native/NativeApp.cs b/MediaBrowser.ServerApplication/Native/NativeApp.cs
index 0e114b166d..c0d3e876a5 100644
--- a/MediaBrowser.ServerApplication/Native/NativeApp.cs
+++ b/MediaBrowser.ServerApplication/Native/NativeApp.cs
@@ -33,5 +33,17 @@ namespace MediaBrowser.ServerApplication.Native
return MainStartup.CanSelfRestart;
}
}
+
+ /// <summary>
+ /// Gets 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 static bool CanSelfUpdate
+ {
+ get
+ {
+ return MainStartup.CanSelfUpdate;
+ }
+ }
}
}