feat: add signal cmd

This commit is contained in:
braginini
2021-04-15 15:10:39 +02:00
parent 303f955e32
commit b72fceab40
4 changed files with 64 additions and 21 deletions

View File

@@ -1,6 +1,12 @@
package cmd
import "github.com/spf13/cobra"
import (
"fmt"
"github.com/spf13/cobra"
"os"
"os/signal"
"syscall"
)
var (
rootCmd = &cobra.Command{
@@ -17,4 +23,13 @@ func Execute() error {
func init() {
rootCmd.AddCommand(upCmd)
rootCmd.AddCommand(signalCmd)
}
func SetupCloseHandler() {
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
<-c
fmt.Println("\r- Ctrl+C pressed in Terminal")
os.Exit(0)
}