Skip to content

Commit

Permalink
feat(tools): corda AIO start/stop per node #686
Browse files Browse the repository at this point in the history
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 <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Mar 26, 2021
1 parent 529dcaf commit f52c00e
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 29 deletions.
11 changes: 8 additions & 3 deletions tools/docker/corda-all-in-one/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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"]
Expand Down
19 changes: 0 additions & 19 deletions tools/docker/corda-all-in-one/run-corda-network.sh

This file was deleted.

13 changes: 13 additions & 0 deletions tools/docker/corda-all-in-one/run-notary-node.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tools/docker/corda-all-in-one/run-party-a-node.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tools/docker/corda-all-in-one/run-party-b-node.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions tools/docker/corda-all-in-one/run-party-c-node.sh
Original file line number Diff line number Diff line change
@@ -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
47 changes: 40 additions & 7 deletions tools/docker/corda-all-in-one/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit f52c00e

Please sign in to comment.