chore: move shutdown to post hook (#27294)

This commit is contained in:
andig 2026-02-08 11:27:18 +01:00 • committed by GitHub
parent ccf30688d9
commit 3b374f7795
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 11 additions and 33 deletions

View file

@ -46,7 +46,4 @@ func runCacheClear(cmd *cobra.Command, args []string) {
}
log.INFO.Println("Cache cleared successfully")
}
// wait for shutdown
<-shutdownDoneC()
}

View file

@ -142,7 +142,4 @@ func runCharger(cmd *cobra.Command, args []string) {
log.INFO.Println("running heartbeat (if any) until interrupted (Ctrl-C to stop)")
time.Sleep(time.Hour)
}
// wait for shutdown
<-shutdownDoneC()
}

View file

@ -97,7 +97,4 @@ func runChargerRamp(cmd *cobra.Command, args []string) {
}
ramp(v, digits, delay)
}
// wait for shutdown
<-shutdownDoneC()
}

View file

@ -50,7 +50,4 @@ func runDevice(cmd *cobra.Command, args []string) {
fmt.Println()
}
}
// wait for shutdown
<-shutdownDoneC()
}

View file

@ -96,7 +96,4 @@ func runMeter(cmd *cobra.Command, args []string) {
log.INFO.Println("running heartbeat (if any) until interrupted (Ctrl-C to stop)")
time.Sleep(time.Hour)
}
// wait for shutdown
<-shutdownDoneC()
}

View file

@ -80,6 +80,4 @@ func runMigrate(cmd *cobra.Command, args []string) {
// clear config table
result := db.Instance.Delete(&config.Config{}, "true")
log.INFO.Printf(" %d entries deleted", result.RowsAffected)
// wait for shutdown
<-shutdownDoneC()
}

View file

@ -41,7 +41,4 @@ func runPasswordReset(cmd *cobra.Command, args []string) {
if confirm {
auth.New().RemoveAdminPassword()
}
// wait for shutdown
<-shutdownDoneC()
}

View file

@ -43,7 +43,4 @@ func runPasswordSet(cmd *cobra.Command, args []string) {
} else {
auth.New().SetAdminPassword(password)
}
// wait for shutdown
<-shutdownDoneC()
}

View file

@ -66,6 +66,7 @@ var rootCmd = &cobra.Command{
Run: runRoot,
// always allow Ctrl-C in child commands
PersistentPreRun: allowCtrlC,
PersistentPostRun: awaitShutdown,
}
func init() {
@ -151,6 +152,15 @@ func allowCtrlC(cmd *cobra.Command, args []string) {
}()
}
func awaitShutdown(cmd *cobra.Command, args []string) {
if cmd.Name() == rootName {
return
}
// wait for shutdown
<-shutdownDoneC()
}
func runRoot(cmd *cobra.Command, args []string) {
runAsService = true

View file

@ -51,7 +51,4 @@ func runSettingsSet(cmd *cobra.Command, args []string) {
if confirmation {
settings.SetString(args[0], args[1])
}
// wait for shutdown
<-shutdownDoneC()
}

View file

@ -90,7 +90,4 @@ func runTariff(cmd *cobra.Command, args []string) {
fmt.Println()
}
// wait for shutdown
<-shutdownDoneC()
}

View file

@ -132,7 +132,4 @@ func runVehicle(cmd *cobra.Command, args []string) {
}
}
}
// wait for shutdown
<-shutdownDoneC()
}