Run ex-bond-issuance automation from command line

Hey DAMLer’s!

After exploring ex-bond-issuance repo and after talking to @Richard_Kapolnai, I do want to try and incorporate the triggers in the repo. I was previously going to try and incorporate without the automation but the triggers seem pretty slick and I want to give them a shot.

Earlier, I got things up and running in Standalone from the windows command line with the help of @Gary_Verhaegen and @cocreature. These were the steps we cam up with:

python scripts/getfinlib.py 1.7.0
daml build -o target/bond-issuance.dar
daml start --sandbox-option --address=localhost --sandbox-option -w --open-browser no
## insert manual 'make automation' steps here
daml codegen js target/bond-issuance.dar -o daml.js
daml codegen js target/finlib-1.7.0.dar -o daml.js
cd ui-js
yarn install
set NODE_ENV=development
yarn start

I’d like to now add the make automation steps to the sequence. From the Makefile, the steps are:

.PHONY: automation
automation:
  JAVA_TOOL_OPTIONS=-Xmx128m \
  scripts/waitForSandbox.sh localhost 6865 && \
  scripts/startTriggers.sh localhost 6865 target/bond-issuance.dar

My guess is that they would look something like this:

set JAVA_TOOL_OPTIONS=-Xmx128m 
java scripts/waitForSandbox.sh localhost 6865
java scripts/startTriggers.sh localhost 6865 target/bond-issuance.dar

When I do this, this is the result:

C:\Users\James Jaworski\OneDrive\Optimis\bloqbook-v2\ex-bond-issuance-master>set JAVA_TOOL_OPTIONS=-Xmx128m
C:\Users\James Jaworski\OneDrive\Optimis\bloqbook-v2\ex-bond-issuance-master>java scripts/waitForSandbox.sh localhost 6865
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Error: Could not find or load main class scripts.waitForSandbox.sh

It looks like the environment variable is being set, but the rest is not running. Is anyone familiar with running this type of command on a Windows machine? My version of java is:

C:\Users\James Jaworski\OneDrive\Optimis\bloqbook-v2\ex-bond-issuance-master>java -version
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

Thanks!

Hi @jamesljaworski85, the .sh extension of the two scripts indicates that this is a shell script (more specifically bash). Running those using java is not going to work. Instead you have to look at the content of those scripts and translate it to powershell/cmd.exe commands.

wait_for_sandbox.sh doesn’t do anything except for waiting for Sandbox to start so the easiest option is probably to just wait until you see Sandbox starting up before you invoke the next command.

startTriggers.sh actually starts the triggers. If you look at the contents, you can see that it invokes the following 10 times for different triggers ex-bond-issuance/startTriggers.sh at 9f801c393e8bd6be0a2a59105284521b8628e2a1 · digital-asset/ex-bond-issuance · GitHub. Since triggers are long-running processes you need to invoke that from 10 different terminals replacing the DAR, the trigger name, the party and the ledger host and port in the command.

  daml trigger \
      --wall-clock-time \
      --dar "${DAR_FILE}" \
      --trigger-name "$trigger_name" \
      --ledger-host "${SANDBOX_HOST}" \
      --ledger-port "${SANDBOX_PORT}" \
      --ledger-party "$party"
2 Likes

Thanks @cocreature. After reading that it would take 10 different command windows (in addition to the two others I already had running), I decided to download Gitbash and run it from there. I was able to get it up and running and work through some of the examples.

Thanks for your help!

2 Likes

Glad to hear that you got it working!

1 Like