forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner.go
43 lines (35 loc) · 1.15 KB
/
runner.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
// Copyright (C) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package runner
import (
"fmt"
"os"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"
"github.com/haowang0402/avalanchego/app"
"github.com/haowang0402/avalanchego/app/process"
"github.com/haowang0402/avalanchego/node"
appplugin "github.com/haowang0402/avalanchego/app/plugin"
)
// Run an AvalancheGo node.
// If specified in the config, serves a hashicorp plugin that can be consumed by
// the daemon (see avalanchego/main).
func Run(config Config, nodeConfig node.Config) {
nodeApp := process.NewApp(nodeConfig) // Create node wrapper
if config.PluginMode { // Serve as a plugin
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: appplugin.Handshake,
Plugins: map[string]plugin.Plugin{
appplugin.Name: appplugin.New(nodeApp),
},
GRPCServer: plugin.DefaultGRPCServer, // A non-nil value here enables gRPC serving for this plugin
Logger: hclog.New(&hclog.LoggerOptions{
Level: hclog.Error,
}),
})
return
}
fmt.Println(process.Header)
exitCode := app.Run(nodeApp)
os.Exit(exitCode)
}