From 296cb1b184eb3b1c16e508b4e7f5f5e8f9c8625f Mon Sep 17 00:00:00 2001 From: Radu Ometita Date: Mon, 17 Jan 2022 21:37:44 +0200 Subject: [PATCH] Make the alonzo node command not exit. --- plutus-pab-executables/tx-inject/config.yaml | 3 ++- plutus-pab/src/Plutus/PAB/Run/Cli.hs | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/plutus-pab-executables/tx-inject/config.yaml b/plutus-pab-executables/tx-inject/config.yaml index b9ddcad6bf..8a8debb4b2 100644 --- a/plutus-pab-executables/tx-inject/config.yaml +++ b/plutus-pab-executables/tx-inject/config.yaml @@ -16,7 +16,8 @@ nodeServerConfig: pscBaseUrl: http://localhost:9082 pscSocketPath: /tmp/node-server.sock pscKeptBlocks: 100000 - pscNetworkId: "1097911063" + # pscNetworkId: "1097911063" + pscNetworkId: "3" pscSlotConfig: scSlotZeroTime: 1596059091000 # Wednesday, July 29, 2020 21:44:51 - shelley launch time in milliseconds scSlotLength: 1000 # In milliseconds diff --git a/plutus-pab/src/Plutus/PAB/Run/Cli.hs b/plutus-pab/src/Plutus/PAB/Run/Cli.hs index 61ee02b529..e576b63257 100644 --- a/plutus-pab/src/Plutus/PAB/Run/Cli.hs +++ b/plutus-pab/src/Plutus/PAB/Run/Cli.hs @@ -29,11 +29,11 @@ import Cardano.Node.Types (NodeMode (AlonzoNode, MockNode), import Cardano.Wallet.Mock.Server qualified as WalletServer import Cardano.Wallet.Mock.Types (WalletMsg) import Cardano.Wallet.Types (WalletConfig (LocalWalletConfig, RemoteWalletConfig)) -import Control.Concurrent (takeMVar) +import Control.Concurrent (takeMVar, threadDelay) import Control.Concurrent.Async (Async, async, waitAny) import Control.Concurrent.Availability (Availability, available, starting) import Control.Concurrent.STM qualified as STM -import Control.Monad (forM, forM_, void) +import Control.Monad (forM, forM_, forever, void) import Control.Monad.Freer (Eff, LastMember, Member, interpret, runM) import Control.Monad.Freer.Delay (DelayEffect, delayThread, handleDelayEffect) import Control.Monad.Freer.Error (throwError) @@ -133,7 +133,10 @@ runConfigCommand _ ConfigCommandArgs{ccaTrace, ccaPABConfig = Config {nodeServer $ logInfo @(LM.AppMsg (Builtin a)) $ LM.PABMsg $ LM.SCoreMsg LM.ConnectingToAlonzoNode - pure () -- TODO: Log message that we're connecting to the real Alonzo node + -- The semantics of Command(s) is that once a set of commands are + -- started if any finishes the entire application is terminated. We want + -- to prevent that by keeping the thread suspended. + forever $ threadDelay 1000000000 -- Run PAB webserver runConfigCommand contractHandler ConfigCommandArgs{ccaTrace, ccaPABConfig=config@Config{pabWebserverConfig, dbConfig}, ccaAvailability, ccaStorageBackend} PABWebserver = @@ -182,10 +185,11 @@ runConfigCommand contractHandler c@ConfigCommandArgs{ccaAvailability, ccaPABConf let shouldStartMocks = case pscNodeMode nodeServerConfig of MockNode -> True AlonzoNode -> False + startedCommands = filter (mockedServices shouldStartMocks) commands in void $ do - threads <- traverse forkCommand - $ filter (mockedServices shouldStartMocks) commands - putStrLn "Started all commands." + putStrLn $ "Starting all commands (" <> show startedCommands <> ")." + threads <- traverse forkCommand startedCommands + putStrLn $ "Started all commands (" <> show startedCommands <> ")." waitAny threads where mockedServices :: Bool -> ConfigCommand -> Bool