2018-07-09 02:40:34 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"runtime"
|
|
|
|
|
|
|
|
"github.com/prysmaticlabs/geth-sharding/sharding/node"
|
|
|
|
"github.com/prysmaticlabs/geth-sharding/sharding/utils"
|
2018-07-14 03:35:15 +00:00
|
|
|
"github.com/prysmaticlabs/geth-sharding/shared/debug"
|
2018-07-14 02:15:37 +00:00
|
|
|
log "github.com/sirupsen/logrus"
|
2018-07-09 02:40:34 +00:00
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
func startNode(ctx *cli.Context) error {
|
|
|
|
shardingNode, err := node.New(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
// starts a connection to a beacon node and kicks off every registered service.
|
|
|
|
shardingNode.Start()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
cli.AppHelpTemplate = `NAME:
|
|
|
|
{{.Name}} - {{.Usage}}
|
|
|
|
USAGE:
|
|
|
|
{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}
|
|
|
|
{{if len .Authors}}
|
|
|
|
AUTHOR:
|
|
|
|
{{range .Authors}}{{ . }}{{end}}
|
|
|
|
{{end}}{{if .Commands}}
|
|
|
|
GLOBAL OPTIONS:
|
|
|
|
{{range .VisibleFlags}}{{.}}
|
|
|
|
{{end}}{{end}}{{if .Copyright }}
|
|
|
|
COPYRIGHT:
|
|
|
|
{{.Copyright}}
|
|
|
|
{{end}}{{if .Version}}
|
|
|
|
VERSION:
|
|
|
|
{{.Version}}
|
|
|
|
{{end}}
|
|
|
|
`
|
|
|
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "sharding"
|
|
|
|
app.Usage = `launches a sharding client that interacts with a beacon chain, starts proposer services, shardp2p connections, and more
|
|
|
|
`
|
|
|
|
app.Action = startNode
|
2018-07-14 03:35:15 +00:00
|
|
|
app.Flags = []cli.Flag{utils.ActorFlag, utils.DataDirFlag, utils.PasswordFileFlag, utils.NetworkIdFlag, utils.IPCPathFlag, utils.DepositFlag, utils.ShardIDFlag, debug.PProfFlag, debug.PProfAddrFlag, debug.PProfPortFlag, debug.MemProfileRateFlag, debug.CPUProfileFlag, debug.TraceFlag}
|
2018-07-09 02:40:34 +00:00
|
|
|
|
|
|
|
app.Before = func(ctx *cli.Context) error {
|
|
|
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
2018-07-15 19:06:36 +00:00
|
|
|
return debug.Setup(ctx)
|
2018-07-09 02:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.After = func(ctx *cli.Context) error {
|
2018-07-14 03:35:15 +00:00
|
|
|
debug.Exit()
|
2018-07-09 02:40:34 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
2018-07-14 02:15:37 +00:00
|
|
|
log.Error(err.Error())
|
2018-07-09 02:40:34 +00:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|