2017-10-03 17:26:44 +02:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2017-12-28 18:14:33 +01:00
|
|
|
"os"
|
|
|
|
"os/signal"
|
2017-10-03 17:26:44 +02:00
|
|
|
"sync"
|
2017-12-28 18:14:33 +01:00
|
|
|
"syscall"
|
2017-10-03 17:26:44 +02:00
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
var testCmd = &cobra.Command{
|
|
|
|
Use: "test",
|
|
|
|
Short: "For testing stuff",
|
|
|
|
Run: test,
|
|
|
|
}
|
|
|
|
RootCmd.AddCommand(testCmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
func test(cmd *cobra.Command, args []string) {
|
|
|
|
var wg sync.WaitGroup
|
2017-12-28 18:14:33 +01:00
|
|
|
c := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
|
|
|
wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer wg.Done()
|
|
|
|
<-c
|
|
|
|
log.Println("got signal")
|
|
|
|
}()
|
|
|
|
log.Println("waiting for ctrl+c")
|
2017-10-03 17:26:44 +02:00
|
|
|
wg.Wait()
|
2017-12-28 18:14:33 +01:00
|
|
|
log.Println("done waiting")
|
2017-10-03 17:26:44 +02:00
|
|
|
}
|