Skip to content

Commit

Permalink
Make the alonzo node command not exit.
Browse files Browse the repository at this point in the history
  • Loading branch information
raduom committed Jan 17, 2022
1 parent 83551a0 commit 296cb1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion plutus-pab-executables/tx-inject/config.yaml
Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions plutus-pab/src/Plutus/PAB/Run/Cli.hs
Expand Up @@ -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)
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 296cb1b

Please sign in to comment.