-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServiceHandler.cs
40 lines (31 loc) · 1.08 KB
/
ServiceHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using BSS.Logging;
using System;
using System.ServiceProcess;
using System.Threading;
#pragma warning disable CS0618
namespace Wrapper
{
internal sealed class Service : ServiceBase
{
internal static readonly Thread MainThread = new(Worker.Run) { Name = "MainWorkerThread" };
public Service()
{
AutoLog = false;
CanHandlePowerEvent = false;
CanPauseAndContinue = false;
CanShutdown = true;
CanStop = true;
ServiceName = "Nginx Wrapper";
}
protected override void OnStart(String[] args) => MainThread.Start();
protected override void OnStop() => Shutdown();
protected override void OnShutdown() => Shutdown();
internal static void Shutdown()
{
Log.FastLog("Received Win32 shutdown signal", LogSeverity.Info, "ServiceBase");
MainThread.Resume();
MainThread.Join();
Log.FastLog("Successful shut down, exiting", LogSeverity.Info, "ServiceBase");
}
}
}