Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit a119c29

Browse files
iohk-bors[bot]KtorZ
andcommitted
Merge #4051
4051: Disable node monitoring API by default r=disassembler a=KtorZ ## Description <!--- A brief description of this PR and the problem is trying to solve --> Instead of using default arguments pointing to files that may or may not be present. It's better to simply not have it by default, and activate it only when needed ## Linked issue <!--- Put here the relevant issue from YouTrack --> Co-authored-by: KtorZ <[email protected]>
2 parents 0bb4e77 + cd8b177 commit a119c29

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed

lib/src/Pos/Client/CLI/NodeOptions.hs

+12-19
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ import Data.Version (showVersion)
2525
import NeatInterpolation (text)
2626
import Options.Applicative (Parser, auto, execParser, footerDoc,
2727
fullDesc, header, help, helper, info, infoOption, long,
28-
metavar, option, progDesc, showDefault, strOption, switch,
29-
value)
28+
metavar, option, progDesc, strOption, switch, value)
3029
import Text.PrettyPrint.ANSI.Leijen (Doc)
3130

3231
import Paths_cardano_sl (version)
3332

3433
import Pos.Client.CLI.Options (CommonArgs (..), commonArgsParser,
3534
optionalJSONPath, templateParser)
36-
import Pos.Core.NetworkAddress (NetworkAddress, addrParser, localhost)
35+
import Pos.Core.NetworkAddress (NetworkAddress, addrParser)
3736
import Pos.Infra.HealthCheck.Route53 (route53HealthCheckOption)
3837
import Pos.Infra.InjectFail (FInjectsSpec, parseFInjectsSpec)
3938
import Pos.Infra.Network.CLI (NetworkConfigOpts, networkConfigOption)
@@ -162,7 +161,7 @@ nodeArgsParser = NodeArgs <$> behaviorParser
162161
metavar "FILE" <>
163162
help "Path to the behavior config"
164163

165-
data NodeWithApiArgs = NodeWithApiArgs CommonNodeArgs NodeArgs NodeApiArgs
164+
data NodeWithApiArgs = NodeWithApiArgs CommonNodeArgs NodeArgs (Maybe NodeApiArgs)
166165

167166
nodeWithApiArgsParser :: Parser NodeWithApiArgs
168167
nodeWithApiArgsParser =
@@ -171,22 +170,19 @@ nodeWithApiArgsParser =
171170
<*> nodeArgsParser
172171
<*> nodeApiArgsParser
173172

174-
nodeApiArgsParser :: Parser NodeApiArgs
175-
nodeApiArgsParser =
176-
NodeApiArgs
177-
<$> addressParser "node-api-address" (localhost, 8080)
178-
<*> tlsParamsParser
179-
<*> debugModeParser
180-
<*> addressParser "node-doc-address" (localhost, 8180)
173+
nodeApiArgsParser :: Parser (Maybe NodeApiArgs)
174+
nodeApiArgsParser = optional $ NodeApiArgs
175+
<$> addressParser "node-api-address"
176+
<*> tlsParamsParser
177+
<*> debugModeParser
178+
<*> addressParser "node-doc-address"
181179
where
182-
addressParser flagName defValue =
180+
addressParser :: String -> Parser NetworkAddress
181+
addressParser flagName =
183182
option (fromParsec addrParser) $
184183
long flagName
185184
<> metavar "IP:PORT"
186-
<> help helpMsg
187-
<> showDefault
188-
<> value defValue
189-
helpMsg = "IP and port for backend node API."
185+
<> help "IP and port for backend node API."
190186
debugModeParser :: Parser Bool
191187
debugModeParser =
192188
switch (long "wallet-debug" <>
@@ -216,23 +212,20 @@ tlsParamsParser = constructTlsParams <$> certPathParser
216212
"tlscert"
217213
"FILEPATH"
218214
"Path to file with TLS certificate"
219-
<> value "scripts/tls-files/server.crt"
220215
)
221216

222217
keyPathParser :: Parser FilePath
223218
keyPathParser = strOption (templateParser
224219
"tlskey"
225220
"FILEPATH"
226221
"Path to file with TLS key"
227-
<> value "scripts/tls-files/server.key"
228222
)
229223

230224
caPathParser :: Parser FilePath
231225
caPathParser = strOption (templateParser
232226
"tlsca"
233227
"FILEPATH"
234228
"Path to file with TLS certificate authority"
235-
<> value "scripts/tls-files/ca.crt"
236229
)
237230

238231
noClientAuthParser :: Parser Bool

node/app/Main.hs

+10-8
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,22 @@ import Pos.Client.CLI (NodeWithApiArgs (..), getNodeApiOptions,
1010
loggingParams)
1111
import Pos.Launcher (actionWithCoreNode, launchNode)
1212
import Pos.Util.CompileInfo (compileInfo, withCompileInfo)
13+
import Pos.Util.Wlog (logInfo)
1314

1415
main :: IO ()
1516
main = withCompileInfo $ do
16-
NodeWithApiArgs cArgs nArgs apiArgs <- getNodeApiOptions
17+
NodeWithApiArgs cArgs nArgs mApiArgs <- getNodeApiOptions
1718
let lArgs = loggingParams "node" cArgs
19+
20+
let nodeServer = case mApiArgs of
21+
Nothing ->
22+
\_ _ _ _ _ _ -> logInfo "Monitoring API is disabled."
23+
Just apiArgs ->
24+
launchNodeServer apiArgs
25+
1826
launchNode nArgs cArgs lArgs
1927
$ \genConfig walConfig txpConfig ntpConfig nodeParams sscParams nodeResources ->
2028
actionWithCoreNode
21-
(launchNodeServer
22-
apiArgs
23-
ntpConfig
24-
nodeResources
25-
updateConfiguration
26-
compileInfo
27-
genConfig)
29+
(nodeServer ntpConfig nodeResources updateConfiguration compileInfo genConfig)
2830
genConfig walConfig txpConfig
2931
ntpConfig nodeParams sscParams nodeResources

0 commit comments

Comments
 (0)