Add IPC path command line flag (#1229)

This commit is contained in:
Ivan Daniluk 2018-10-11 12:29:59 +02:00 committed by GitHub
parent 802197879a
commit 4d5f808085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 11 deletions

View File

@ -36,6 +36,8 @@ var (
configFiles configFlags
logLevel = flag.String("log", "", `Log level, one of: "ERROR", "WARN", "INFO", "DEBUG", and "TRACE"`)
logWithoutColors = flag.Bool("log-without-color", false, "Disables log colors")
ipcEnabled = flag.Bool("ipc", false, "Enable IPC RPC endpoint")
ipcFile = flag.String("ipcfile", "", "Set IPC file path")
pprofEnabled = flag.Bool("pprof", false, "Enable runtime profiling via pprof")
pprofPort = flag.Int("pprof-port", 52525, "Port for runtime profiling via pprof")
version = flag.Bool("version", false, "Print version and dump configuration")
@ -105,6 +107,12 @@ func main() {
config.RegisterTopics = append(config.RegisterTopics, params.WhisperDiscv5Topic)
}
// enable IPC RPC
if *ipcEnabled {
config.IPCEnabled = true
config.IPCFile = *ipcFile
}
// set up logging options
setupLogging(config)

View File

@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"os"
"path"
"path/filepath"
"time"
@ -128,12 +127,20 @@ func newGethNodeConfig(config *params.NodeConfig) (*node.Config, error) {
MaxPeers: config.MaxPeers,
MaxPendingPeers: config.MaxPendingPeers,
},
IPCPath: makeIPCPath(config),
HTTPCors: nil,
HTTPModules: config.FormatAPIModules(),
HTTPVirtualHosts: []string{"localhost"},
}
if config.IPCEnabled {
// use well-known defaults
if config.IPCFile == "" {
config.IPCFile = "geth.ipc"
}
nc.IPCPath = config.IPCFile
}
if config.HTTPEnabled {
nc.HTTPHost = config.HTTPHost
nc.HTTPPort = config.HTTPPort
@ -322,15 +329,6 @@ func activateShhService(stack *node.Node, config *params.NodeConfig, db *leveldb
})
}
// makeIPCPath returns IPC-RPC filename
func makeIPCPath(config *params.NodeConfig) string {
if !config.IPCEnabled {
return ""
}
return path.Join(config.DataDir, config.IPCFile)
}
// parseNodes creates list of discover.Node out of enode strings.
func parseNodes(enodes []string) []*discover.Node {
var nodes []*discover.Node