|
|
@ -30,7 +30,6 @@ import ( |
|
|
|
"github.com/harmony-one/harmony/node" |
|
|
|
"github.com/harmony-one/harmony/node" |
|
|
|
"github.com/harmony-one/harmony/p2p" |
|
|
|
"github.com/harmony-one/harmony/p2p" |
|
|
|
"github.com/harmony-one/harmony/p2p/p2pimpl" |
|
|
|
"github.com/harmony-one/harmony/p2p/p2pimpl" |
|
|
|
"github.com/natefinch/lumberjack" |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
@ -62,24 +61,6 @@ func printVersion() { |
|
|
|
os.Exit(0) |
|
|
|
os.Exit(0) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func initLogFile(logFolder, role, ip, port string, onlyLogTps bool, logMaxSize int) { |
|
|
|
|
|
|
|
// Setup a logger to stdout and log file.
|
|
|
|
|
|
|
|
if err := os.MkdirAll(logFolder, 0755); err != nil { |
|
|
|
|
|
|
|
panic(err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
utils.AddLogHandler( |
|
|
|
|
|
|
|
log.StreamHandler(&lumberjack.Logger{ |
|
|
|
|
|
|
|
Filename: fmt.Sprintf("./%v/%s-%v-%v.log", logFolder, role, ip, port), |
|
|
|
|
|
|
|
MaxSize: logMaxSize, |
|
|
|
|
|
|
|
Compress: true, |
|
|
|
|
|
|
|
}, log.JSONFormat())) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if onlyLogTps { |
|
|
|
|
|
|
|
matchFilterHandler := log.MatchFilterHandler("msg", "TPS Report", utils.GetLogInstance().GetHandler()) |
|
|
|
|
|
|
|
utils.GetLogInstance().SetHandler(matchFilterHandler) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
|
ip = flag.String("ip", "127.0.0.1", "ip of the node") |
|
|
|
ip = flag.String("ip", "127.0.0.1", "ip of the node") |
|
|
|
port = flag.String("port", "9000", "port of the node.") |
|
|
|
port = flag.String("port", "9000", "port of the node.") |
|
|
@ -157,10 +138,6 @@ func initSetup() { |
|
|
|
// Setup mem profiling.
|
|
|
|
// Setup mem profiling.
|
|
|
|
memprofiling.GetMemProfiling().Config() |
|
|
|
memprofiling.GetMemProfiling().Config() |
|
|
|
|
|
|
|
|
|
|
|
// Logging setup
|
|
|
|
|
|
|
|
utils.SetLogContext(*port, *ip) |
|
|
|
|
|
|
|
utils.SetLogVerbosity(log.Lvl(*verbosity)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set default keystore Dir
|
|
|
|
// Set default keystore Dir
|
|
|
|
hmykey.DefaultKeyStoreDir = *keystoreDir |
|
|
|
hmykey.DefaultKeyStoreDir = *keystoreDir |
|
|
|
|
|
|
|
|
|
|
@ -459,13 +436,20 @@ func main() { |
|
|
|
} |
|
|
|
} |
|
|
|
blsPassphrase = passphrase |
|
|
|
blsPassphrase = passphrase |
|
|
|
|
|
|
|
|
|
|
|
// Configure log parameters
|
|
|
|
|
|
|
|
utils.SetLogContext(*port, *ip) |
|
|
|
|
|
|
|
utils.SetLogVerbosity(log.Lvl(*verbosity)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initSetup() |
|
|
|
initSetup() |
|
|
|
nodeConfig := createGlobalConfig() |
|
|
|
nodeConfig := createGlobalConfig() |
|
|
|
initLogFile(*logFolder, nodeConfig.StringRole, *ip, *port, *onlyLogTps, *logMaxSize) |
|
|
|
|
|
|
|
|
|
|
|
// Logging setup
|
|
|
|
|
|
|
|
utils.SetLogContext(*port, *ip) |
|
|
|
|
|
|
|
utils.SetLogVerbosity(log.Lvl(*verbosity)) |
|
|
|
|
|
|
|
filename := fmt.Sprintf("%v/%s-%v-%v.log", *logFolder, nodeConfig.StringRole, *ip, *port) |
|
|
|
|
|
|
|
if err := utils.AddLogFile(filename, *logMaxSize); err != nil { |
|
|
|
|
|
|
|
panic(err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if *onlyLogTps { |
|
|
|
|
|
|
|
matchFilterHandler := log.MatchFilterHandler("msg", "TPS Report", utils.GetLogInstance().GetHandler()) |
|
|
|
|
|
|
|
utils.GetLogInstance().SetHandler(matchFilterHandler) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Start Profiler for leader if profile argument is on
|
|
|
|
// Start Profiler for leader if profile argument is on
|
|
|
|
if nodeConfig.StringRole == "leader" && (*profile || *metricsReportURL != "") { |
|
|
|
if nodeConfig.StringRole == "leader" && (*profile || *metricsReportURL != "") { |
|
|
|