Skip to content

Commit

Permalink
Make the socket-path option optional
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed May 8, 2024
1 parent ed2b2b4 commit c3e66af
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
10 changes: 8 additions & 2 deletions lib/local-cluster/exe/local-cluster.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ import System.Directory
import System.Environment.Extended
( isEnvSet
)
import System.IO.Extra
( withTempFile
)
import System.IO.Temp.Extra
( SkipCleanup (..)
, withSystemTempDir
Expand All @@ -92,7 +95,7 @@ import System.Path
, parse
, relDir
, relFile
, (</>)
, (</>), absFile
)
import UnliftIO.Concurrent
( threadDelay
Expand Down Expand Up @@ -261,6 +264,9 @@ main = withUtf8 $ do
fmap (DirOf . absDir)
$ ContT
$ withSystemTempDir tr "test-cluster" skipCleanup
socketPath <- case nodeToClientSocket of
Just path -> pure path
Nothing -> FileOf . absFile <$> ContT withTempFile
let clusterCfg =
Cluster.Config
{ cfgStakePools = Cluster.defaultPoolConfigs
Expand All @@ -274,7 +280,7 @@ main = withUtf8 $ do
, cfgNodeOutputFile = Nothing
, cfgRelayNodePath = mkRelDirOf "relay"
, cfgClusterLogFile = clusterLogs
, cfgNodeToClientSocket = nodeToClientSocket
, cfgNodeToClientSocket = socketPath
}
(_, phaseTracer) <- withSNetworkId (NTestnet 42)
$ \network -> do
Expand Down
19 changes: 11 additions & 8 deletions lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/CommandLine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ data CommandLineOptions = CommandLineOptions
, clusterDir :: Maybe (DirOf "cluster")
, clusterLogs :: Maybe (FileOf "cluster-logs")
, minSeverity :: Maybe Severity
, nodeToClientSocket :: FileOf "node-to-client-socket"
, nodeToClientSocket :: Maybe (FileOf "node-to-client-socket")
, monitoring :: MonitorConfiguration
}
deriving stock (Show)
Expand Down Expand Up @@ -156,14 +156,17 @@ httpApiPortParser = do
validPorts :: [PortNumber]
validPorts = [1024 .. 65535]

nodeToClientSocketParser :: Absolutizer -> Parser (FileOf "node-to-client-socket")
nodeToClientSocketParser
:: Absolutizer
-> Parser (Maybe (FileOf "node-to-client-socket"))
nodeToClientSocketParser (Absolutizer absOf) =
FileOf . absOf . absRel
<$> strOption
( long "socket-path"
<> metavar "NODE_TO_CLIENT_SOCKET"
<> help "Path to the node-to-client socket"
)
optional
$ FileOf . absOf . absRel
<$> strOption
( long "socket-path"
<> metavar "NODE_TO_CLIENT_SOCKET"
<> help "Path to the node-to-client socket"
)

clusterConfigsDirParser :: Absolutizer -> Parser (DirOf "cluster-configs")
clusterConfigsDirParser (Absolutizer absOf) =
Expand Down
1 change: 1 addition & 0 deletions lib/local-cluster/local-cluster.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ executable local-cluster
, cardano-wallet-primitive
, contra-tracer
, directory
, extra
, iohk-monitoring-extra
, lens
, local-cluster
Expand Down

0 comments on commit c3e66af

Please sign in to comment.