12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package daemon
- import (
- "git.beejay.kim/tool/service/config"
- "github.com/urfave/cli/v2"
- "os"
- "path/filepath"
- )
- var flags = []cli.Flag{
- &cli.PathFlag{
- Name: "config",
- Usage: "config file path",
- Required: true,
- Aliases: []string{"C"},
- TakesFile: false,
- Action: config.Load[Configuration],
- },
- &cli.StringFlag{
- Name: "topic",
- Usage: "kafka producer topic name",
- Required: true,
- Destination: &topic,
- Aliases: []string{"T"},
- },
- &cli.StringFlag{
- Name: "pid",
- Usage: "platform ID",
- Required: true,
- Destination: &pid,
- },
- &cli.StringFlag{
- Name: "bid",
- Usage: "broadcaster ID",
- Required: true,
- Destination: &bid,
- },
- &cli.PathFlag{
- Name: "out",
- TakesFile: false,
- Destination: &path,
- Action: func(ctx *cli.Context, path cli.Path) error {
- var (
- f *os.File
- err error
- )
- defer func() {
- if f == nil {
- return
- }
- _ = f.Close()
- _ = os.Remove(f.Name())
- }()
- if f, err = os.OpenFile(
- filepath.Join(path, ".watchdog"),
- os.O_APPEND|os.O_WRONLY|os.O_CREATE,
- 0666); err != nil {
- return err
- }
- return nil
- },
- },
- }
|