This repository has been archived by the owner on May 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 346
/
start.go
55 lines (40 loc) · 1.46 KB
/
start.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
package commands
import (
"context"
cli "github.com/jawher/mow.cli"
)
func Start(output Output) func(cmd *cli.Cmd) {
return func(cmd *cli.Cmd) {
genesisOpt := cmd.StringOpt("g genesis", "",
"Use the specified genesis JSON file rather than a key in the main config, use - to read from STDIN")
configOpt := cmd.StringOpt("c config", "", "Use the a specified burrow config file")
restoreDumpOpt := cmd.StringOpt("restore-dump", "", "Restore new chain from backup")
cmd.Spec = "[--config=<config file>] [--genesis=<genesis json file>] [--restore-dump=<burrow dump file>]"
configOpts := addConfigOptions(cmd)
cmd.Action = func() {
conf, err := obtainBurrowConfig(*configOpt, *genesisOpt)
if err != nil {
output.Fatalf("could not obtain config: %v", err)
}
err = configOpts.configure(conf)
if err != nil {
output.Fatalf("could not update burrow config: %v", err)
}
if conf.ValidatorAddress == nil {
output.Fatalf("could not finalise validator address - please provide one in config or via --validator-address")
}
output.Logf("Using validator address: %s", *conf.ValidatorAddress)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
kern, err := conf.Kernel(ctx, *restoreDumpOpt)
if err != nil {
output.Fatalf("could not create Burrow kernel: %v", err)
}
err = kern.Boot()
if err != nil {
output.Fatalf("could not boot Burrow kernel: %v", err)
}
kern.WaitForShutdown()
}
}
}