From 1df1a6ea81e3c8e9914637067f2d456807ed1cb1 Mon Sep 17 00:00:00 2001 From: andig Date: Wed, 3 May 2023 08:10:57 +0200 Subject: [PATCH] Add shutdown handler (#7787) --- cmd/root.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/root.go b/cmd/root.go index 1d9ad570d..4b78c976b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -250,6 +250,10 @@ func runRoot(cmd *cobra.Command, args []string) { // show main ui if err == nil { httpd.RegisterSiteHandlers(site, cache) + httpd.RegisterShutdownHandler(func() { + log.FATAL.Println("evcc was stopped by user. OS should restart the service. Or restart manually.") + once.Do(func() { close(stopC) }) // signal loop to end + }) // set channels site.DumpConfig()