Browse Source

Added is running as service to IServerApplicationHost

Luke Pulverenti 11 years ago
parent
commit
d39f8a1161

+ 6 - 0
MediaBrowser.Controller/IServerApplicationHost.cs

@@ -20,6 +20,12 @@ namespace MediaBrowser.Controller
         /// <value>The name of the web application.</value>
         /// <value>The name of the web application.</value>
         string WebApplicationName { get; }
         string WebApplicationName { get; }
 
 
+        /// <summary>
+        /// Gets a value indicating whether this instance is running as service.
+        /// </summary>
+        /// <value><c>true</c> if this instance is running as service; otherwise, <c>false</c>.</value>
+        bool IsRunningAsService { get; }
+
         /// <summary>
         /// <summary>
         /// Gets a value indicating whether [supports automatic run at startup].
         /// Gets a value indicating whether [supports automatic run at startup].
         /// </summary>
         /// </summary>

+ 7 - 1
MediaBrowser.Model/System/SystemInfo.cs

@@ -19,7 +19,13 @@ namespace MediaBrowser.Model.System
         /// </summary>
         /// </summary>
         /// <value>The operating sytem.</value>
         /// <value>The operating sytem.</value>
         public string OperatingSystem { get; set; }
         public string OperatingSystem { get; set; }
-        
+
+        /// <summary>
+        /// Gets or sets a value indicating whether this instance is running as service.
+        /// </summary>
+        /// <value><c>true</c> if this instance is running as service; otherwise, <c>false</c>.</value>
+        public bool IsRunningAsService { get; set; }
+
         /// <summary>
         /// <summary>
         /// Gets or sets the mac address.
         /// Gets or sets the mac address.
         /// </summary>
         /// </summary>

+ 10 - 3
MediaBrowser.ServerApplication/ApplicationHost.cs

@@ -179,10 +179,16 @@ namespace MediaBrowser.ServerApplication
         /// </summary>
         /// </summary>
         /// <param name="applicationPaths">The application paths.</param>
         /// <param name="applicationPaths">The application paths.</param>
         /// <param name="logManager">The log manager.</param>
         /// <param name="logManager">The log manager.</param>
-        public ApplicationHost(ServerApplicationPaths applicationPaths, ILogManager logManager)
+        public ApplicationHost(ServerApplicationPaths applicationPaths, ILogManager logManager, bool isRunningAsService)
             : base(applicationPaths, logManager)
             : base(applicationPaths, logManager)
         {
         {
+            _isRunningAsService = isRunningAsService;
+        }
 
 
+        private readonly bool _isRunningAsService;
+        public bool IsRunningAsService
+        {
+            get { return _isRunningAsService; }
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -431,7 +437,7 @@ namespace MediaBrowser.ServerApplication
             await ItemRepository.Initialize().ConfigureAwait(false);
             await ItemRepository.Initialize().ConfigureAwait(false);
 
 
             await ProviderRepository.Initialize().ConfigureAwait(false);
             await ProviderRepository.Initialize().ConfigureAwait(false);
-            
+
             ((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
             ((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
         }
         }
 
 
@@ -687,7 +693,8 @@ namespace MediaBrowser.ServerApplication
                 WanAddress = GetWanAddress(),
                 WanAddress = GetWanAddress(),
                 HasUpdateAvailable = _hasUpdateAvailable,
                 HasUpdateAvailable = _hasUpdateAvailable,
                 SupportsAutoRunAtStartup = SupportsAutoRunAtStartup,
                 SupportsAutoRunAtStartup = SupportsAutoRunAtStartup,
-                TranscodingTempPath = ApplicationPaths.TranscodingTempPath
+                TranscodingTempPath = ApplicationPaths.TranscodingTempPath,
+                IsRunningAsService = IsRunningAsService
             };
             };
         }
         }
 
 

+ 1 - 1
MediaBrowser.ServerApplication/MainStartup.cs

@@ -212,7 +212,7 @@ namespace MediaBrowser.ServerApplication
             SystemEvents.SessionEnding += SystemEvents_SessionEnding;
             SystemEvents.SessionEnding += SystemEvents_SessionEnding;
             SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
             SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
 
 
-            _appHost = new ApplicationHost(appPaths, logManager);
+            _appHost = new ApplicationHost(appPaths, logManager, runService);
 
 
             _app = new App(_appHost, _appHost.LogManager.GetLogger("App"), runService);
             _app = new App(_appHost, _appHost.LogManager.GetLogger("App"), runService);