From 14957791f7c92eb6a028445cc77009c946e37237 Mon Sep 17 00:00:00 2001 From: Carlos Roman Date: Fri, 28 Jul 2023 17:32:55 +0100 Subject: [PATCH] Needed a quick way to init the server --- tools/misbehaving-jmx-server/Dockerfile | 13 ++++++++++++- tools/misbehaving-jmx-server/scripts/init.sh | 16 ++++++++++++++++ tools/misbehaving-jmx-server/scripts/startup.sh | 5 +++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 tools/misbehaving-jmx-server/scripts/init.sh create mode 100755 tools/misbehaving-jmx-server/scripts/startup.sh diff --git a/tools/misbehaving-jmx-server/Dockerfile b/tools/misbehaving-jmx-server/Dockerfile index 3d46e0f77..fd27097b3 100644 --- a/tools/misbehaving-jmx-server/Dockerfile +++ b/tools/misbehaving-jmx-server/Dockerfile @@ -22,6 +22,17 @@ WORKDIR /app # Copy the JAR file from the Maven image to the final image COPY --from=build /app/target/misbehavingjmxserver-1.0-SNAPSHOT-jar-with-dependencies.jar . +COPY scripts/startup.sh scripts/init.sh /app/ +# Default ports +EXPOSE 1099 +EXPOSE 8080 +EXPOSE 8088 + +# Used for testcontainers +EXPOSE 9090 +EXPOSE 9091 +EXPOSE 9092 # Run the supervisor class from the jar -CMD ["java", "-cp", "misbehavingjmxserver-1.0-SNAPSHOT-jar-with-dependencies.jar", "org.datadog.supervisor.App"] +#CMD ["java", "cp", "misbehavingjmxserver-1.0-SNAPSHOT-jar-with-dependencies.jar", "org.datadog.supervisor.App"] +CMD ["/app/startup.sh"] \ No newline at end of file diff --git a/tools/misbehaving-jmx-server/scripts/init.sh b/tools/misbehaving-jmx-server/scripts/init.sh new file mode 100755 index 000000000..7f698b3d6 --- /dev/null +++ b/tools/misbehaving-jmx-server/scripts/init.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Wait for port 8088 to be available +until curl -s -o /dev/null localhost:8088 +do + sleep 5 +done + +# Make a curl request +curl http://localhost:8080/your-api-endpoint +# http POST localhost:8088/init rmiHostname=192.168.160.3 +IP_ADDRESS=`awk 'END{print $1}' /etc/hosts` +echo "Host is ${IP_ADDRESS}" +curl --silent --show-error -o /dev/null -X POST -H 'Content-Type: application/json' -d "{\"rmiHostname\":\"${IP_ADDRESS}\"}" localhost:8088/init + +# http POST localhost:8080/beans/Bohnanza numDesiredBeans=5 diff --git a/tools/misbehaving-jmx-server/scripts/startup.sh b/tools/misbehaving-jmx-server/scripts/startup.sh new file mode 100755 index 000000000..daf376209 --- /dev/null +++ b/tools/misbehaving-jmx-server/scripts/startup.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +nohup ./init.sh & + +java -cp misbehavingjmxserver-1.0-SNAPSHOT-jar-with-dependencies.jar "org.datadog.supervisor.App"