Log when running tray app

This commit is contained in:
Mark McDowall 2017-08-31 22:43:01 -07:00
parent bc32ad064e
commit 728f553802
No known key found for this signature in database
GPG Key ID: D4CEFA9A718052E0
3 changed files with 12 additions and 5 deletions

View File

@ -1,5 +1,3 @@
using System;
namespace NzbDrone.Common.EnvironmentInfo namespace NzbDrone.Common.EnvironmentInfo
{ {
public interface IRuntimeInfo public interface IRuntimeInfo
@ -7,6 +5,7 @@ namespace NzbDrone.Common.EnvironmentInfo
bool IsUserInteractive { get; } bool IsUserInteractive { get; }
bool IsAdmin { get; } bool IsAdmin { get; }
bool IsWindowsService { get; } bool IsWindowsService { get; }
bool IsWindowsTray { get; }
bool IsExiting { get; set; } bool IsExiting { get; set; }
bool RestartPending { get; set; } bool RestartPending { get; set; }
string ExecutingApplication { get; } string ExecutingApplication { get; }

View File

@ -1,10 +1,11 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Security.Principal; using System.Security.Principal;
using System.ServiceProcess; using System.ServiceProcess;
using NLog; using NLog;
using NzbDrone.Common.Processes;
namespace NzbDrone.Common.EnvironmentInfo namespace NzbDrone.Common.EnvironmentInfo
{ {
@ -27,6 +28,7 @@ namespace NzbDrone.Common.EnvironmentInfo
if (entry != null) if (entry != null)
{ {
ExecutingApplication = entry.Location; ExecutingApplication = entry.Location;
IsWindowsTray = entry.ManifestModule.Name == $"{ProcessProvider.NZB_DRONE_PROCESS_NAME}.exe";
} }
} }
@ -102,5 +104,7 @@ namespace NzbDrone.Common.EnvironmentInfo
return true; return true;
} }
public bool IsWindowsTray { get; private set; }
} }
} }

View File

@ -1,6 +1,7 @@
using NLog; using NLog;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Common.Composition; using NzbDrone.Common.Composition;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
namespace NzbDrone.Host namespace NzbDrone.Host
@ -10,18 +11,21 @@ namespace NzbDrone.Host
private readonly INzbDroneServiceFactory _nzbDroneServiceFactory; private readonly INzbDroneServiceFactory _nzbDroneServiceFactory;
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
private readonly IConsoleService _consoleService; private readonly IConsoleService _consoleService;
private readonly IRuntimeInfo _runtimeInfo;
private readonly IContainer _container; private readonly IContainer _container;
private readonly Logger _logger; private readonly Logger _logger;
public Router(INzbDroneServiceFactory nzbDroneServiceFactory, public Router(INzbDroneServiceFactory nzbDroneServiceFactory,
IServiceProvider serviceProvider, IServiceProvider serviceProvider,
IConsoleService consoleService, IConsoleService consoleService,
IRuntimeInfo runtimeInfo,
IContainer container, IContainer container,
Logger logger) Logger logger)
{ {
_nzbDroneServiceFactory = nzbDroneServiceFactory; _nzbDroneServiceFactory = nzbDroneServiceFactory;
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
_consoleService = consoleService; _consoleService = consoleService;
_runtimeInfo = runtimeInfo;
_container = container; _container = container;
_logger = logger; _logger = logger;
} }
@ -44,7 +48,7 @@ namespace NzbDrone.Host
case ApplicationModes.Interactive: case ApplicationModes.Interactive:
{ {
_logger.Debug("Console selected"); _logger.Debug(_runtimeInfo.IsWindowsTray ? "Tray selected" : "Console selected");
DbFactory.RegisterDatabase(_container); DbFactory.RegisterDatabase(_container);
_nzbDroneServiceFactory.Start(); _nzbDroneServiceFactory.Start();