2using System.Collections.Generic;
3using System.Diagnostics;
4using System.Runtime.Versioning;
5using System.ServiceProcess;
8using Microsoft.Extensions.Logging;
9using Microsoft.Extensions.Logging.EventLog;
19 [SupportedOSPlatform(
"windows")]
45#pragma warning disable CA2213
47#pragma warning restore CA2213
61 loggerFactory =
new Lazy<ILoggerFactory>(() => LoggerFactory.Create(builder => builder.AddEventLog(
new EventLogSettings
63 LogName = EventLog.Log,
64 MachineName = EventLog.MachineName,
65 SourceName = EventLog.Source,
66 Filter = (message, logLevel) => logLevel >= minimumLogLevel,
76 protected override void Dispose(
bool disposing)
86 base.Dispose(disposing);
93 protected override void OnStart(
string[] args)
97 "--General:SetupWizardMode=Never",
101 newArgs.AddRange(args);
114 oldLifetime?.DisposeAsync().GetAwaiter().GetResult();
const string CanonicalPackageName
The name of the project.
Represents a IWatchdog as a ServiceBase.
override void OnCustomCommand(int command)
volatile? ServiceLifetime serviceLifetime
The active ServiceLifetime.
override void OnStart(string[] args)
readonly IWatchdogFactory watchdogFactory
The IWatchdog for the ServerService.
readonly Lazy< ILoggerFactory > loggerFactory
The Lazy<T> ILoggerFactory used by the ServerService.
override void Dispose(bool disposing)
const string Name
The canonical windows service name.
ServerService(IWatchdogFactory watchdogFactory, string[] commandLineArguments, LogLevel minimumLogLevel)
Initializes a new instance of the ServerService class.
readonly string[] commandLineArguments
The Array of command line arguments the service was invoked with.
void Run()
Executes the ServerService.
Represents the lifetime of the service.
void HandleCustomCommand(int command)
Handle a custom service command .
Factory for creating IWatchdogs.
IWatchdog CreateWatchdog(ISignalChecker signalChecker, ILoggerFactory loggerFactory)
Create a IWatchdog.