Does Daml Sandbox Script provide any return status, looking for suggestions
- rikotacardsOP 1
Trying to automate a few processes here in a bash script to
- run daml sandbox, and once the dars are uploaded
- run daml json api
- run the daml script to run the init script, which will populate parties
- run a few triggers.
Currently I have the below code (scroll down a bit). I’m using
wait 10, which does the job, but it’s a workaround, as the sandbox process is not guaranteed to take 10 seconds, and I need it to be running before I populate the parties.Daml sandbox doesn’t output any completion status does it? apart from indicating
Canton setup is completeor something like that.the start script below:
daml sandbox --dar main/Asset/asset.dar --dar main/User/user.dar --dar main/Account/account.dar & sleep 10 daml json-api --config json-api-app.conf & echo "launching ledger init script" daml script --ledger-host localhost --ledger-port 6865 --dar main/account/account.dar --script-name Init:setup & sleep 10 echo "ledger init script finished" echo "starting Daml triggers" daml trigger --dar triggers/triggers.dar \ --trigger-name SendAssetHoldingAccountInviteTrigger:sendAssetHoldingAccountInviteTrigger \ --ledger-host localhost \ --ledger-port 6865 \ --ledger-user "admin" & daml trigger --dar triggers/triggers.dar \ --trigger-name AcceptAirdropRequestTrigger:acceptAirdropRequestTrigger \ --ledger-host localhost \ --ledger-port 6865 \ --ledger-user "admin" & daml trigger --dar triggers/triggers.dar \ --trigger-name AcceptAssetInviteTrigger:acceptAssetInviteTrigger \ --ledger-host localhost \ --ledger-port 6865 \ --ledger-user "admin" & daml trigger --dar triggers/triggers.dar \ --trigger-name AcceptSwapTrigger:acceptSwapTrigger \ --ledger-host localhost \ --ledger-port 6865 \ --ledger-user "admin" & waitReason for wanting to add a bit of convenience is currently, to run the app locally we need to
- build dars
- codgen
- cd ui, npm i
- run daml sandbox
- run json-api server
- run daml script to populate parties
- run triggers (there are 4, so then its 4 separate terminal windows)
Ideally, we can just have one script that does everything.
- gyorgybalazsi
Part of these steps is performed by the
daml startcommand, except for the triggers. You can specify the init script in thedaml yamlfile. - cocreature 3
There are two main options here:
-
daml starthas an--on-startoption. You can specify the script there that you want to run once sandbox is up. - If you don’t want to use
daml start, you can use the--port-fileoption todaml sandboxand wait for that file to be created. This also works nicely in tests where you can start sandbox on port 0 to use any free port and then read the port provided by the OS from that file.
-
- gyorgybalazsi
cocreature:daml starthas an--on-startoption. You can specify the script there that you want to run once sandbox is up.You can run a Daml script of a Bash script in this way? I guess for launching a Trigger you would need a Bash script. If just a Daml script, how is this option different from the init script specified in the
daml.yamlfile? - cocreature 2
It runs a bash script not a daml script so you can put whatever you want in there.
- gyorgybalazsi 1
Thank you Moritz, that’s very useful.
- rikotacards
Thanks for this! Will try out the --port-file option.
- rikotacards
Just to clarify, does the --port-file option, is it supposed to create a
logfolder? withcanton_errors.logandcanton.log? and as long as this file is generated, it means that the sandbox has been set up?Before using the portfile option, I would sometimes see this directory being created at the root of my folder. (not sure why or how)
- rikotacards
Actually, it seems like that log directory is always generated when I start sandbox.
- cocreature 1
Yes the log directory is completely independent of this.
--port-file yourportfilehereonly createsyourportfilehere.