From 93e4449b0026468ca8d02863810c35c06bd5320f Mon Sep 17 00:00:00 2001 From: Alexandr Stelnykovych Date: Wed, 30 Apr 2025 12:33:18 +0300 Subject: [PATCH] =?UTF-8?q?(Windows)=20fix:=20UI=20restart=20=E2=80=93=20d?= =?UTF-8?q?o=20not=20send=20"shutdown"=20event=20during=20restart?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmds/cmdbase/service_windows.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmds/cmdbase/service_windows.go b/cmds/cmdbase/service_windows.go index 26468a69..4cb974b9 100644 --- a/cmds/cmdbase/service_windows.go +++ b/cmds/cmdbase/service_windows.go @@ -94,6 +94,7 @@ func (s *WindowsSystemService) Execute(args []string, changeRequests <-chan svc. syscall.SIGTERM, ) + isShuttingDown := false // Wait for shutdown signal. waitSignal: for { @@ -119,12 +120,16 @@ waitSignal: } case <-s.instance.ShuttingDown(): + isShuttingDown = true break waitSignal } } - // Trigger shutdown. - s.instance.Shutdown() + // Trigger shutdown, + // but only if we are not already shutting down. + if !isShuttingDown { + s.instance.Shutdown() + } // Notify the service host that service is in shutting down state. changes <- svc.Status{State: svc.StopPending}