-
Notifications
You must be signed in to change notification settings - Fork 24
/
main.go
41 lines (37 loc) · 1006 Bytes
/
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
package main
import (
"github.com/alecthomas/kong"
konghcl "github.com/alecthomas/kong-hcl/v2"
"github.com/squareup/pranadb/errors"
"github.com/squareup/pranadb/loadrunner"
plog "github.com/squareup/pranadb/log"
"log"
"os"
)
type arguments struct {
Config kong.ConfigFlag `help:"Path to config file" type:"existingfile" required:""`
Log plog.Config `help:"Configuration for the logger" embed:"" prefix:"log-"`
Server loadrunner.Config `help:"LoadRunner configuration" embed:"" prefix:""`
}
func main() {
if err := run(os.Args[1:]); err != nil {
log.Fatal(err)
}
select {} // prevent main exiting
}
func run(args []string) error {
cfg := arguments{}
parser, err := kong.New(&cfg, kong.Configuration(konghcl.Loader))
if err != nil {
return errors.WithStack(err)
}
_, err = parser.Parse(args)
if err != nil {
return errors.WithStack(err)
}
if err := cfg.Server.Validate(); err != nil {
return err
}
pr := loadrunner.NewLoadRunner(cfg.Server)
return pr.Start()
}