From f52c00ec37490c4eb553ec5accbe503ca775fa25 Mon Sep 17 00:00:00 2001 From: Peter Somogyvari Date: Thu, 25 Mar 2021 18:04:30 -0700 Subject: [PATCH] feat(tools): corda AIO start/stop per node #686 With this change the users of the Corda AIO image can decide which nodes to launch (A,B,C,Notary) exactly. Adds scripts to launch individual nodes as needed. Before this we could only launch all the nodes at once which did not work out well because it caused race conditions in the cordapp jar deployment code. This revision is tagged in the container registry as: hyperledger/cactus-corda-4-6-all-in-one-obligation:2021-03-19-feat-686 Fixes #686 Signed-off-by: Peter Somogyvari --- tools/docker/corda-all-in-one/Dockerfile | 11 +++-- .../corda-all-in-one/run-corda-network.sh | 19 -------- .../corda-all-in-one/run-notary-node.sh | 13 +++++ .../corda-all-in-one/run-party-a-node.sh | 9 ++++ .../corda-all-in-one/run-party-b-node.sh | 9 ++++ .../corda-all-in-one/run-party-c-node.sh | 13 +++++ .../docker/corda-all-in-one/supervisord.conf | 47 ++++++++++++++++--- 7 files changed, 92 insertions(+), 29 deletions(-) delete mode 100755 tools/docker/corda-all-in-one/run-corda-network.sh create mode 100755 tools/docker/corda-all-in-one/run-notary-node.sh create mode 100755 tools/docker/corda-all-in-one/run-party-a-node.sh create mode 100755 tools/docker/corda-all-in-one/run-party-b-node.sh create mode 100755 tools/docker/corda-all-in-one/run-party-c-node.sh diff --git a/tools/docker/corda-all-in-one/Dockerfile b/tools/docker/corda-all-in-one/Dockerfile index c915b0fe4f..edb8598fef 100644 --- a/tools/docker/corda-all-in-one/Dockerfile +++ b/tools/docker/corda-all-in-one/Dockerfile @@ -96,8 +96,8 @@ EXPOSE 10014 # Corda IOU Web GUIs for Node A,B,C # EXPOSE 10009 10012 10015 -# Jolokia -# EXPOSE 7005 7006 7007 7008 +# Jolokia for Party A,B,C and Notary +EXPOSE 7005 7006 7007 7008 # P2P messaging (localhost bound), RPC, admin RPC # EXPOSE 10002 10003 10103 @@ -106,10 +106,13 @@ EXPOSE 10014 # EXPOSE 10013 10014 10114 COPY supervisord.conf /etc/supervisord.conf -COPY run-corda-network.sh / COPY run-party-a-server.sh / COPY run-party-b-server.sh / COPY run-party-c-server.sh / +COPY run-party-a-node.sh / +COPY run-party-b-node.sh / +COPY run-party-c-node.sh / +COPY run-notary-node.sh / COPY healthcheck.sh / # By default we only run the absolute minimum which is a single party's node. @@ -126,6 +129,8 @@ ENV PARTY_B_WEB_SRV_ENABLED="false" ENV PARTY_C_NODE_ENABLED="true" ENV PARTY_C_WEB_SRV_ENABLED="false" +ENV NOTARY_NODE_ENABLED="true" + # Extend the parent image's entrypoint # https://superuser.com/questions/1459466/can-i-add-an-additional-docker-entrypoint-script ENTRYPOINT ["/usr/bin/supervisord"] diff --git a/tools/docker/corda-all-in-one/run-corda-network.sh b/tools/docker/corda-all-in-one/run-corda-network.sh deleted file mode 100755 index e9089a0f11..0000000000 --- a/tools/docker/corda-all-in-one/run-corda-network.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -set -e - -if [ "$PARTY_A_NODE_ENABLED" != "true" ] -then - rm -rf ./build/nodes/ParticipantA* -fi - -if [ "$PARTY_B_NODE_ENABLED" != "true" ] -then - rm -rf ./build/nodes/ParticipantB* -fi - -if [ "$PARTY_C_NODE_ENABLED" != "true" ] -then - rm -rf ./build/nodes/ParticipantC* -fi - -./build/nodes/runnodes diff --git a/tools/docker/corda-all-in-one/run-notary-node.sh b/tools/docker/corda-all-in-one/run-notary-node.sh new file mode 100755 index 0000000000..9d9aa6b234 --- /dev/null +++ b/tools/docker/corda-all-in-one/run-notary-node.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +if [ "$NOTARY_NODE_ENABLED" = "true" ] +then + java \ + -Dcapsule.jvm.args="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5008 -javaagent:drivers/jolokia-jvm-1.6.0-agent.jar=port=7008,logHandlerClass=net.corda.node.JolokiaSlf4jAdapter" \ + -Dname=Notary \ + -jar \ + /samples-kotlin/Advanced/obligation-cordapp/build/nodes/Notary/corda.jar +else + sleep infinity +fi diff --git a/tools/docker/corda-all-in-one/run-party-a-node.sh b/tools/docker/corda-all-in-one/run-party-a-node.sh new file mode 100755 index 0000000000..0078bb8f5b --- /dev/null +++ b/tools/docker/corda-all-in-one/run-party-a-node.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -e + +if [ "$PARTY_A_NODE_ENABLED" = "true" ] +then + java -Dcapsule.jvm.args="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -javaagent:drivers/jolokia-jvm-1.6.0-agent.jar=port=7005,logHandlerClass=net.corda.node.JolokiaSlf4jAdapter" -Dname=ParticipantA -jar /samples-kotlin/Advanced/obligation-cordapp/build/nodes/ParticipantA/corda.jar +else + sleep infinity +fi diff --git a/tools/docker/corda-all-in-one/run-party-b-node.sh b/tools/docker/corda-all-in-one/run-party-b-node.sh new file mode 100755 index 0000000000..a2546ee95a --- /dev/null +++ b/tools/docker/corda-all-in-one/run-party-b-node.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -e + +if [ "$PARTY_B_NODE_ENABLED" = "true" ] +then + java -Dcapsule.jvm.args="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5006 -javaagent:drivers/jolokia-jvm-1.6.0-agent.jar=port=7006,logHandlerClass=net.corda.node.JolokiaSlf4jAdapter" -Dname=ParticipantB -jar /samples-kotlin/Advanced/obligation-cordapp/build/nodes/ParticipantB/corda.jar +else + sleep infinity +fi diff --git a/tools/docker/corda-all-in-one/run-party-c-node.sh b/tools/docker/corda-all-in-one/run-party-c-node.sh new file mode 100755 index 0000000000..8755b78e41 --- /dev/null +++ b/tools/docker/corda-all-in-one/run-party-c-node.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +if [ "$PARTY_C_NODE_ENABLED" = "true" ] +then + java \ + -Dcapsule.jvm.args="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5007 -javaagent:drivers/jolokia-jvm-1.6.0-agent.jar=port=7007,logHandlerClass=net.corda.node.JolokiaSlf4jAdapter" \ + -Dname=ParticipantC \ + -jar \ + /samples-kotlin/Advanced/obligation-cordapp/build/nodes/ParticipantC/corda.jar +else + sleep infinity +fi diff --git a/tools/docker/corda-all-in-one/supervisord.conf b/tools/docker/corda-all-in-one/supervisord.conf index 090e516321..ea1da295bf 100644 --- a/tools/docker/corda-all-in-one/supervisord.conf +++ b/tools/docker/corda-all-in-one/supervisord.conf @@ -10,6 +10,9 @@ supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=http://127.0.0.1:9001 +[inet_http_server] +port = 0.0.0.0:9001 + [program:sshd] command=/usr/sbin/sshd -D -ddd autostart=true @@ -30,10 +33,44 @@ stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 -[program:corda-network] -command=/run-corda-network.sh +[program:corda-a] +directory=/samples-kotlin/Advanced/obligation-cordapp/build/nodes/ParticipantA/ +command=/run-party-a-node.sh autostart=true -autorestart=unexpected +autorestart=false +exitcodes=0 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + +[program:corda-b] +directory=/samples-kotlin/Advanced/obligation-cordapp/build/nodes/ParticipantB +command=/run-party-b-node.sh +autostart=true +autorestart=false +exitcodes=0 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + +[program:corda-c] +directory=/samples-kotlin/Advanced/obligation-cordapp/build/nodes/ParticipantC +command=/run-party-c-node.sh +autostart=true +autorestart=false +exitcodes=0 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + +[program:corda-n] +directory=/samples-kotlin/Advanced/obligation-cordapp/build/nodes/Notary +command=/run-notary-node.sh +autostart=true +autorestart=false exitcodes=0 stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 @@ -69,7 +106,3 @@ stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 - -[inet_http_server] -port = 0.0.0.0:9001 -