/
main.go
92 lines (77 loc) · 2.67 KB
/
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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Modifications Copyright 2019 The klaytn Authors
// Copyright 2016 The go-ethereum Authors
// This file is part of go-ethereum.
//
// go-ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
//
// This file is derived from cmd/geth/main.go (2018/06/04).
// Modified and improved for the klaytn development.
package main
import (
"fmt"
"os"
"sort"
"github.com/klaytn/klaytn/api/debug"
"github.com/klaytn/klaytn/cmd/utils"
"github.com/klaytn/klaytn/cmd/utils/nodecmd"
"github.com/klaytn/klaytn/console"
"github.com/klaytn/klaytn/log"
"gopkg.in/urfave/cli.v1"
)
var (
logger = log.NewModuleLogger(log.CMDKSEN)
// The app that holds all commands and flags.
app = utils.NewApp(nodecmd.GetGitCommit(), "The command line interface for Klaytn Endpoint Node")
)
func init() {
utils.InitHelper()
// Initialize the CLI app and start ksen
app.Action = nodecmd.RunKlaytnNode
app.HideVersion = true // we have a command to print the version
app.Copyright = "Copyright 2018-2019 The klaytn Authors"
app.Commands = []cli.Command{
// See utils/nodecmd/chaincmd.go:
nodecmd.InitCommand,
nodecmd.DumpGenesisCommand,
// See utils/nodecmd/accountcmd.go
nodecmd.AccountCommand,
// See utils/nodecmd/consolecmd.go:
nodecmd.GetConsoleCommand(nodecmd.KsenNodeFlags(), nodecmd.CommonRPCFlags),
nodecmd.AttachCommand,
// See utils/nodecmd/versioncmd.go:
nodecmd.VersionCommand,
// See utils/nodecmd/dumpconfigcmd.go:
nodecmd.GetDumpConfigCommand(nodecmd.KsenNodeFlags(), nodecmd.CommonRPCFlags),
}
sort.Sort(cli.CommandsByName(app.Commands))
app.Flags = nodecmd.KsenAppFlags()
cli.AppHelpTemplate = utils.GlobalAppHelpTemplate
cli.HelpPrinter = utils.NewHelpPrinter(utils.CategorizeFlags(app.Flags))
app.CommandNotFound = nodecmd.CommandNotExist
app.OnUsageError = nodecmd.OnUsageError
app.Before = nodecmd.BeforeRunNode
app.After = func(ctx *cli.Context) error {
debug.Exit()
console.Stdin.Close() // Resets terminal mode.
return nil
}
}
func main() {
// Set NodeTypeFlag to sen
utils.NodeTypeFlag.Value = "sen"
if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}