Can I specify several dars to be uploaded when using the `daml start` command?
App Development4 posts209 views2 likesLast activity Jun 2022
GY
gyorgybalazsiOP
Jun 2022I know I can pass several dars to the daml sandbox command to be uploaded to Sandbox.
In addition to uploading several dars, I also would like to run a script after Sandbox is ready, which is possible using the --on-start option of the daml start command.
I would like to combine these two features.
CO
cocreature
Jun 2022There is no builtin feature for this. You have a few options:
- Don’t use daml start. You can use
daml sandbox --port-file portfileand then wait forportfileto be created as an indication that sandbox is up. Even in something like a bash script waiting for a file to be created is reasonably simple. - A DAR includes its dependencies. So if your project depends on other DARs, those should get uploaded as well. Note that you actually need to use them though (as in have a reference to them). Just putting them in
data-dependenciesisn’t going to include them. - You could put
daml ledger upload-darcommands in youron-startscript.
GY
gyorgybalazsi
Jun 2022Thank you!
RI
rikotacards
Jun 2022For some practical examples, in my start.sh file, I have something like :
cantonPortFile="./canton-sandbox-port.txt"
jsonApiPortFile="./json-api-port.txt"
daml sandbox --dar main/Asset/asset.dar --dar main/User/user.dar --dar main/Account/account.dar --port-file ${cantonPortFile}
The below waits for the sandbox file to be created, then you can run another command after, for example, I’ll allocate parties.
waitForSandBox(){
while [ ! -f "$cantonPortFile" ];
do
echo "Setting up sandbox..."
if [ "$timeout" == 0 ]; then
echo "ERROR: Timeout while waiting for the file ${cantonPortFile}"
exit 1
sleep 2 # or less like 0.2
fi
sleep 1
((timeout--))
done
echo "Canton sandBox setup complete"
}
The json api server can also create a port-file, which outputs the file once the server is setup, which you can then run triggers.
{
server {
address = "localhost"
port = 7575
port-file="json-api-port.txt"
}
ledger-api {
address = "localhost"
port = 6865
}
}