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

@ -65,7 +65,8 @@ var rootCmd = &cobra.Command{
Version: util.FormattedVersion(),
Run: runRoot,
// always allow Ctrl-C in child commands
PersistentPreRun: allowCtrlC,
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