1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-01 00:12:30 +01:00
Sonarr/NzbDrone.Update/UpdateEngine/StartNzbDrone.cs
2013-05-20 21:03:05 -07:00

45 lines
1.4 KiB
C#

using System.IO;
using NLog;
using NzbDrone.Common;
namespace NzbDrone.Update.UpdateEngine
{
public interface IStartNzbDrone
{
void Start(AppType appType, string installationFolder);
}
public class StartNzbDrone : IStartNzbDrone
{
private readonly IServiceProvider _serviceProvider;
private readonly IProcessProvider _processProvider;
private readonly Logger _logger;
public StartNzbDrone(IServiceProvider serviceProvider, IProcessProvider processProvider, Logger logger)
{
_serviceProvider = serviceProvider;
_processProvider = processProvider;
_logger = logger;
}
public void Start(AppType appType, string installationFolder)
{
_logger.Info("Starting NzbDrone");
if (appType == AppType.Service)
{
_logger.Info("Starting NzbDrone service");
_serviceProvider.Start(ServiceProvider.NZBDRONE_SERVICE_NAME);
}
else if (appType == AppType.Console)
{
_logger.Info("Starting NzbDrone with Console");
_processProvider.Start(Path.Combine(installationFolder, "NzbDrone.Console.exe"));
}
else
{
_logger.Info("Starting NzbDrone without Console");
_processProvider.Start(Path.Combine(installationFolder, "NzbDrone.exe"));
}
}
}
}