123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package daemon
- import (
- "errors"
- "git.beejay.kim/WatchDog/ward/player"
- "github.com/urfave/cli/v2"
- "os"
- "os/signal"
- "syscall"
- )
- var (
- topic string
- pid string
- bid string
- pathRecord string
- pathPlayer string
- players []player.Player
- exit = make(chan error, 8)
- ctrlSignal = make(chan os.Signal)
- Command = cli.Command{
- Name: "daemon",
- Usage: "run daemon",
- Flags: flags,
- Action: action,
- Before: func(ctx *cli.Context) error {
- // Intercept Interrupt signals
- signal.Notify(ctrlSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
- go func() {
- <-ctrlSignal
- exit <- errors.New("interrupted by user")
- }()
- var (
- p player.Player
- err error
- )
- if pathRecord != "" {
- if p, err = player.NewRecorder(pathRecord, bid); err != nil {
- return err
- }
- players = append(players, p)
- }
- if pathPlayer == "vlc" {
- if p, err = player.NewVLC(ctx.Context); err != nil {
- return err
- }
- players = append(players, p)
- }
- return nil
- },
- }
- )
|