-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
73 lines (66 loc) · 1.69 KB
/
main.go
File metadata and controls
73 lines (66 loc) · 1.69 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"fmt"
"os"
"strings"
"github.com/iotexproject/iotex-core/v2/pkg/log"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
"github.com/iotexproject/iotex-analyser/cmd"
"github.com/iotexproject/iotex-analyser/config"
"github.com/iotexproject/iotex-analyser/kernel"
)
var (
version = "1.3.1"
)
func main() {
app := cli.NewApp()
app.Name = "iotex-analyser"
app.Usage = "async analyser for iotex"
app.Version = version
app.Flags = []cli.Flag{
&cli.StringFlag{
Name: "config",
Aliases: []string{"c"},
Value: config.FindDefaultConfigPath(),
Usage: "Load configuration from `FILE`",
},
}
app.Before = func(c *cli.Context) error {
if c.String("config") == "" {
log.L().Fatal("Cannot determine default configuration path.",
zap.Any("DefaultConfigFiles", config.DefaultConfigFiles),
zap.Any("DefaultConfigDirs", config.DefaultConfigDirs))
}
cfg, err := config.New(c.String("config"))
if err != nil {
return err
}
if err := log.InitLoggers(cfg.Log, cfg.SubLogs); err != nil {
fmt.Fprintf(os.Stderr, "ERROR: Failed to init logger: %v\n", err)
os.Exit(1)
}
config.SetEVMNetworkID(cfg.Iotex.EVMNetworkID)
if cfg.Iotex.EVMNetworkID == 0 {
if strings.Contains(cfg.Iotex.ChainEndPoint, "testnet") {
config.SetEVMNetworkID(4690)
} else {
config.SetEVMNetworkID(4689)
}
}
log.L().Debug("loaded iotex-core configure",
zap.String("version", version),
zap.Uint32("EVMNetworkID", config.EVMNetworkID()),
)
kernel.Init(cfg)
return nil
}
app.Commands = []*cli.Command{
cmd.Server,
cmd.Plugin,
cmd.Tools,
}
if err := app.Run(os.Args); err != nil {
log.L().Error("Failed to start application", zap.Error(err))
}
}