-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.go
More file actions
34 lines (27 loc) · 697 Bytes
/
main.go
File metadata and controls
34 lines (27 loc) · 697 Bytes
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
package main
import (
"context"
"flag"
"os"
"os/signal"
"github.com/google/subcommands"
"github.com/lucklove/mysql-replayer/bench"
"github.com/lucklove/mysql-replayer/prepare"
)
func main() {
subcommands.Register(subcommands.HelpCommand(), "")
subcommands.Register(subcommands.FlagsCommand(), "")
subcommands.Register(subcommands.CommandsCommand(), "")
subcommands.Register(&prepare.PrepareCommand{}, "")
subcommands.Register(&bench.BenchCommand{}, "")
flag.Parse()
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
ch := make(chan os.Signal, 1)
signal.Notify(ch, os.Interrupt)
go func() {
<-ch
cancel()
}()
os.Exit(int(subcommands.Execute(ctx)))
}