A peer-to-peer stack for code collaboration
Improved machine config option
Thomas Scholtesdca5e8f5ed58
diff --git a/README.md b/README.mdindex 5d53a14..2ff68fe 100644--- a/README.md+++ b/README.md@@ -55,7 +55,8 @@ The end-to-end test suite is run with `stack test :e2e`. It requires you tostart up an IPFS test network and the Raicle daemon.docker-compose -f test/docker-compose.yaml up -d ipfs-test-network- RAD_IPFS_API_URL=http://localhost:19301 stack exec -- radicle-daemon --filePrefix test+ RAD_IPFS_API_URL=http://localhost:19301 stack exec -- \+ radicle-daemon --machine-config /tmp/radicle-machines.jsonIf you use `docker-compose up` for the first time you will also need toinitialize the IPFS test network with@@ -63,8 +64,8 @@ initialize the IPFS test network withecho '{"radicle": true}' | \docker-compose -f test/docker-compose.yaml exec -T ipfs-test-network ipfs dag put-You can reset the test daemon’s state by removing the file-`./local/share/radicle/testdaemon-follows`.+You can reset the test daemon’s machine configuration by removing the file+`/tmp/radicle-machines.json`.### Troubleshootingdiff --git a/exe/Daemon.hs b/exe/Daemon.hsindex 3baccdc..a9a365d 100644--- a/exe/Daemon.hs+++ b/exe/Daemon.hs@@ -39,41 +39,53 @@ logDaemonError (displayError -> (m, xs)) = logErr m xs-- * Maindata Opts = Opts- { port :: Int- -- TODO(james): temporary, just for testing.- , filePrefix :: Text- , debug :: Bool+ { port :: Int+ , machineConfigFile :: FilePath+ , debug :: Bool}-opts :: Parser Opts-opts = Opts- <$> option auto+cliInfo :: IO (ParserInfo Opts)+cliInfo = do+ defaultMachineConfigFile <- Local.getRadicleFile "machines.json"+ pure $+ info (opts defaultMachineConfigFile <**> helper)+ ( fullDesc+ <> progDesc "Run the radicle daemon"+ <> header "radicle-daemon"+ )++opts :: FilePath -> Parser Opts+opts defaultMachineConfigFile = do+ port <-+ option auto( long "port"<> help "daemon port"<> metavar "PORT"<> showDefault<> value 8909)- <*> strOption- ( long "filePrefix"- <> help "file prefix"- <> metavar "PREFIX"+ machineConfigFile <-+ strOption+ ( long "machine-config"+ <> help "Where to store configuration for known machines"+ <> metavar "FILE"<> showDefault- <> value ""+ <> value defaultMachineConfigFile)- <*> switch+ debug <-+ switch( long "debug"<> help "enable debug logging"<> showDefault)+ pure $ Opts{..}-- We use 'Void' to enforce the use of 'exitFailure'main :: IO Voidmain = dohSetBuffering stdout LineBuffering- Opts{..} <- execParser allOpts+ Opts{..} <- execParser =<< cliInfomachineConfigFileLock <- newMVar ()- machineConfigFile <- Local.getRadicleFile (toS filePrefix <> "daemon-follows")machines <- CachedMachines <$> CMap.emptylet env = Env{ logLevel = if debug then Debug else Normal, ..}machineConfig <- readMachineConfigIO machineConfigFileLock machineConfigFile@@ -99,12 +111,6 @@ main = doRight (Right ()) -> dologErr "Server stopped (this should not happen)" []exitFailure- where- allOpts = info (opts <**> helper)- ( fullDesc- <> progDesc "Run the radicle daemon"- <> header "radicle-daemon"- )server :: Env -> Server Api.DaemonApiserver env = hoistServer Api.daemonApi nt daemonServerdiff --git a/package.yaml b/package.yamlindex 8f75559..5d2b5df 100644--- a/package.yaml+++ b/package.yaml@@ -206,6 +206,7 @@ executables:default-extensions:- AutoDeriveTypeable+- ApplicativeDo- ConstraintKinds- DataKinds- DefaultSignatures