mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
started to remove iisexpress.
This commit is contained in:
parent
40f3a8663d
commit
68128809c9
39 changed files with 383 additions and 820 deletions
69
NzbDrone.Common/HostController.cs
Normal file
69
NzbDrone.Common/HostController.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using Nancy.Bootstrapper;
|
||||
using Nancy.Hosting.Self;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
public interface IHostController
|
||||
{
|
||||
bool ServerStarted { get; }
|
||||
string AppUrl { get; }
|
||||
void StartServer();
|
||||
void RestartServer();
|
||||
void StopServer();
|
||||
}
|
||||
|
||||
public class HostController : IHostController
|
||||
{
|
||||
private readonly ConfigFileProvider _configFileProvider;
|
||||
private readonly INancyBootstrapper _bootstrapper;
|
||||
private readonly Logger _logger;
|
||||
private NancyHost _host;
|
||||
|
||||
|
||||
public bool ServerStarted { get; private set; }
|
||||
|
||||
public HostController(ConfigFileProvider configFileProvider, INancyBootstrapper bootstrapper, Logger logger)
|
||||
{
|
||||
_configFileProvider = configFileProvider;
|
||||
_bootstrapper = bootstrapper;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void StartServer()
|
||||
{
|
||||
_host = new NancyHost(new Uri(AppUrl), _bootstrapper);
|
||||
}
|
||||
|
||||
public string AppUrl
|
||||
{
|
||||
get { return string.Format("http://localhost:{0}/", _configFileProvider.Port); }
|
||||
}
|
||||
|
||||
|
||||
public void RestartServer()
|
||||
{
|
||||
|
||||
_logger.Warn("Attempting to restart server.");
|
||||
|
||||
if (_host != null)
|
||||
{
|
||||
StopServer();
|
||||
}
|
||||
|
||||
StartServer();
|
||||
}
|
||||
|
||||
public void StopServer()
|
||||
{
|
||||
if (_host == null) return;
|
||||
|
||||
_logger.Info("Attempting to stop Nancy host");
|
||||
_host.Stop();
|
||||
_host = null;
|
||||
_logger.Info("Host has stopped");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue