support run as service

This commit is contained in:
Luke Pulverenti
2013-09-20 21:04:14 -04:00
parent b5615cb233
commit 2e511fba83
16 changed files with 550 additions and 205 deletions

View File

@@ -1,30 +1,40 @@
using System.ServiceProcess;
using MediaBrowser.Model.Logging;
using System.ServiceProcess;
namespace MediaBrowser.ServerApplication
{
/// <summary>
/// Class BackgroundService
/// </summary>
public class BackgroundService : ServiceBase
{
public BackgroundService()
public static string Name = "MediaBrowser";
public static string DisplayName = "Media Browser";
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="BackgroundService"/> class.
/// </summary>
public BackgroundService(ILogger logger)
{
_logger = logger;
CanPauseAndContinue = false;
CanHandleSessionChangeEvent = true;
CanStop = false;
CanShutdown = true;
ServiceName = "Media Browser";
CanStop = true;
ServiceName = Name;
}
protected override void OnSessionChange(SessionChangeDescription changeDescription)
/// <summary>
/// When implemented in a derived class, executes when a Stop command is sent to the service by the Service Control Manager (SCM). Specifies actions to take when a service stops running.
/// </summary>
protected override void OnStop()
{
base.OnSessionChange(changeDescription);
}
_logger.Info("Stop command received");
protected override void OnStart(string[] args)
{
}
protected override void OnShutdown()
{
base.OnShutdown();
base.OnStop();
}
}
}