mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-22 16:54:46 +03:00
support run as service
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user