diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs
index 5554ced376..38a3cc9236 100644
--- a/MediaBrowser.Controller/IServerApplicationHost.cs
+++ b/MediaBrowser.Controller/IServerApplicationHost.cs
@@ -20,6 +20,12 @@ namespace MediaBrowser.Controller
/// The name of the web application.
string WebApplicationName { get; }
+ ///
+ /// Gets a value indicating whether this instance is running as service.
+ ///
+ /// true if this instance is running as service; otherwise, false.
+ bool IsRunningAsService { get; }
+
///
/// Gets a value indicating whether [supports automatic run at startup].
///
diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs
index 3082e80b63..24707b29b3 100644
--- a/MediaBrowser.Model/System/SystemInfo.cs
+++ b/MediaBrowser.Model/System/SystemInfo.cs
@@ -19,7 +19,13 @@ namespace MediaBrowser.Model.System
///
/// The operating sytem.
public string OperatingSystem { get; set; }
-
+
+ ///
+ /// Gets or sets a value indicating whether this instance is running as service.
+ ///
+ /// true if this instance is running as service; otherwise, false.
+ public bool IsRunningAsService { get; set; }
+
///
/// Gets or sets the mac address.
///
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index 4b15ca8d03..91019c0a89 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -179,10 +179,16 @@ namespace MediaBrowser.ServerApplication
///
/// The application paths.
/// The log manager.
- public ApplicationHost(ServerApplicationPaths applicationPaths, ILogManager logManager)
+ public ApplicationHost(ServerApplicationPaths applicationPaths, ILogManager logManager, bool isRunningAsService)
: base(applicationPaths, logManager)
{
+ _isRunningAsService = isRunningAsService;
+ }
+ private readonly bool _isRunningAsService;
+ public bool IsRunningAsService
+ {
+ get { return _isRunningAsService; }
}
///
@@ -431,7 +437,7 @@ namespace MediaBrowser.ServerApplication
await ItemRepository.Initialize().ConfigureAwait(false);
await ProviderRepository.Initialize().ConfigureAwait(false);
-
+
((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
}
@@ -687,7 +693,8 @@ namespace MediaBrowser.ServerApplication
WanAddress = GetWanAddress(),
HasUpdateAvailable = _hasUpdateAvailable,
SupportsAutoRunAtStartup = SupportsAutoRunAtStartup,
- TranscodingTempPath = ApplicationPaths.TranscodingTempPath
+ TranscodingTempPath = ApplicationPaths.TranscodingTempPath,
+ IsRunningAsService = IsRunningAsService
};
}
diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs
index 3021363213..f34c3921d9 100644
--- a/MediaBrowser.ServerApplication/MainStartup.cs
+++ b/MediaBrowser.ServerApplication/MainStartup.cs
@@ -212,7 +212,7 @@ namespace MediaBrowser.ServerApplication
SystemEvents.SessionEnding += SystemEvents_SessionEnding;
SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
- _appHost = new ApplicationHost(appPaths, logManager);
+ _appHost = new ApplicationHost(appPaths, logManager, runService);
_app = new App(_appHost, _appHost.LogManager.GetLogger("App"), runService);