@@ -34,23 +34,7 @@ const cmdRoot = "core"
34
34
// The main command describes the service and
35
35
// defaults to printing the help message.
36
36
var mainCmd = & cobra.Command {
37
- Use : "peer" ,
38
- PersistentPreRunE : func (cmd * cobra.Command , args []string ) error {
39
- // check for --logging-level pflag first, which should override all other
40
- // log settings. if --logging-level is not set, use CORE_LOGGING_LEVEL
41
- // (environment variable takes priority; otherwise, the value set in
42
- // core.yaml)
43
- var loggingSpec string
44
- if viper .GetString ("logging_level" ) != "" {
45
- loggingSpec = viper .GetString ("logging_level" )
46
- } else {
47
- loggingSpec = viper .GetString ("logging.level" )
48
- }
49
- flogging .InitFromSpec (loggingSpec )
50
-
51
- return nil
52
- },
53
- }
37
+ Use : "peer" }
54
38
55
39
func main () {
56
40
// For environment variables.
@@ -78,11 +62,21 @@ func main() {
78
62
os .Exit (1 )
79
63
}
80
64
81
- runtime .GOMAXPROCS (viper .GetInt ("peer.gomaxprocs" ))
82
-
83
65
// setup system-wide logging backend based on settings from core.yaml
84
66
flogging .InitBackend (flogging .SetFormat (viper .GetString ("logging.format" )), logOutput )
85
67
68
+ // check for --logging-level pflag first, which should override all other
69
+ // log settings. if --logging-level is not set, use CORE_LOGGING_LEVEL
70
+ // (environment variable takes priority; otherwise, the value set in
71
+ // core.yaml)
72
+ var loggingSpec string
73
+ if viper .GetString ("logging_level" ) != "" {
74
+ loggingSpec = viper .GetString ("logging_level" )
75
+ } else {
76
+ loggingSpec = viper .GetString ("logging.level" )
77
+ }
78
+ flogging .InitFromSpec (loggingSpec )
79
+
86
80
// Init the MSP
87
81
var mspMgrConfigDir = config .GetPath ("peer.mspConfigPath" )
88
82
var mspID = viper .GetString ("peer.localMspId" )
@@ -95,6 +89,9 @@ func main() {
95
89
logger .Errorf ("Cannot run peer because %s" , err .Error ())
96
90
os .Exit (1 )
97
91
}
92
+
93
+ runtime .GOMAXPROCS (viper .GetInt ("peer.gomaxprocs" ))
94
+
98
95
// On failure Cobra prints the usage message and error string, so we only
99
96
// need to exit with a non-0 status
100
97
if mainCmd .Execute () != nil {
0 commit comments