From 09ff8f8f1216ef27296ea028fd511d83a2d9d831 Mon Sep 17 00:00:00 2001 From: Nathan Leach Date: Mon, 24 Oct 2022 06:42:07 -0500 Subject: [PATCH] shutdown stabilization --- Applications/CxAnalytixCLI/Program.cs | 4 ---- Applications/CxAnalytixDaemon/Daemon.cs | 11 ----------- .../CxAnalytixService/ServiceLifecycleControl.cs | 1 - Libs/Executive/ExecuteLoop.cs | 3 +++ 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/Applications/CxAnalytixCLI/Program.cs b/Applications/CxAnalytixCLI/Program.cs index 669a4dd1..1badfdc3 100644 --- a/Applications/CxAnalytixCLI/Program.cs +++ b/Applications/CxAnalytixCLI/Program.cs @@ -34,9 +34,5 @@ static void Main(string[] args) }); } - private static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) - { - throw new NotImplementedException(); - } } } diff --git a/Applications/CxAnalytixDaemon/Daemon.cs b/Applications/CxAnalytixDaemon/Daemon.cs index bf503071..497686f8 100644 --- a/Applications/CxAnalytixDaemon/Daemon.cs +++ b/Applications/CxAnalytixDaemon/Daemon.cs @@ -24,17 +24,6 @@ public void Dispose() public Task StartAsync(CancellationToken cancellationToken) { _cancelToken = new CancellationTokenSource(); - _cancelToken.Token.Register(() => - { - var token = new CancellationTokenSource(); - - using (var task = StopAsync(token.Token) ) - { - if (!_serviceTask.Wait(120000)) - token.Cancel(); - } - }); - _serviceTask = Task.Run( () => { diff --git a/Applications/CxAnalytixService/ServiceLifecycleControl.cs b/Applications/CxAnalytixService/ServiceLifecycleControl.cs index cbe7f83d..259b8e3e 100644 --- a/Applications/CxAnalytixService/ServiceLifecycleControl.cs +++ b/Applications/CxAnalytixService/ServiceLifecycleControl.cs @@ -53,7 +53,6 @@ protected override void OnStart(string[] args) base.OnStart(args); _cancelToken = new CancellationTokenSource(); - _cancelToken.Token.Register(stopService); _serviceTask = Task.Run( () => { diff --git a/Libs/Executive/ExecuteLoop.cs b/Libs/Executive/ExecuteLoop.cs index 83c24d78..dd0cc8a8 100644 --- a/Libs/Executive/ExecuteLoop.cs +++ b/Libs/Executive/ExecuteLoop.cs @@ -2,6 +2,7 @@ using log4net; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -46,6 +47,8 @@ private static void Fatal(Exception ex, CancellationTokenSource ct) { appLog.Error("Fatal exception caught, program ending.", ex); ct.Cancel(); + Process.GetCurrentProcess().Kill(true); + }