forked from genuinetools/bpfd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
59 lines (48 loc) · 1.23 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"context"
"errors"
"flag"
"github.com/genuinetools/bpfd/version"
"github.com/genuinetools/pkg/cli"
"github.com/sirupsen/logrus"
)
var (
grpcAddress string
debug bool
)
func main() {
// Create a new cli program.
p := cli.NewProgram()
p.Name = "bpfd"
p.Description = "Framework for running BPF tracers with rules on Linux as a daemon"
// Set the GitCommit and Version.
p.GitCommit = version.GITCOMMIT
p.Version = version.VERSION
// Build the list of available commands.
p.Commands = []cli.Command{
&createCommand{},
&daemonCommand{},
&listCommand{},
&removeCommand{},
&traceCommand{},
}
// Setup the global flags.
p.FlagSet = flag.NewFlagSet("bpfd", flag.ExitOnError)
p.FlagSet.BoolVar(&debug, "debug", false, "enable debug logging")
p.FlagSet.BoolVar(&debug, "d", false, "enable debug logging")
p.FlagSet.StringVar(&grpcAddress, "grpc-addr", "/run/bpfd/bpfd.sock", "Address for gRPC api communication")
// Set the before function.
p.Before = func(ctx context.Context) error {
// Set the log level.
if debug {
logrus.SetLevel(logrus.DebugLevel)
}
if len(grpcAddress) < 1 {
return errors.New("gRPC address cannot be empty")
}
return nil
}
// Run our program.
p.Run()
}