lbry.go/cmd/test.go

36 lines
573 B
Go
Raw Normal View History

2017-10-03 17:26:44 +02:00
package cmd
import (
"os"
"os/signal"
2017-10-03 17:26:44 +02:00
"sync"
"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
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()
log.Println("done waiting")
2017-10-03 17:26:44 +02:00
}