From 7dfd8da0dfc3a3996078a7271b4626c212cd9619 Mon Sep 17 00:00:00 2001 From: Matt Riben Date: Wed, 9 Oct 2024 21:31:36 -0500 Subject: [PATCH] feat: run entrypoint as s6 supervised service Signed-off-by: Matt Riben --- .../production-next/consensus-node/Dockerfile | 10 ++++++++-- .../production-next/consensus-node/entrypoint.sh | 2 +- .../etc/s6-overlay/s6-rc.d/hedera/dependencies.d/base | 0 .../consensus-node/etc/s6-overlay/s6-rc.d/hedera/type | 1 + .../consensus-node/etc/s6-overlay/s6-rc.d/hedera/up | 1 + .../consensus-node/etc/s6-overlay/s6-rc.d/hedera/up.sh | 5 +++++ .../etc/s6-overlay/s6-rc.d/user/contents.d/hedera | 0 7 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/dependencies.d/base create mode 100644 hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/type create mode 100644 hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/up create mode 100644 hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/up.sh create mode 100644 hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/user/contents.d/hedera diff --git a/hedera-node/infrastructure/docker/containers/production-next/consensus-node/Dockerfile b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/Dockerfile index ea1e528756b5..6e059cdea603 100644 --- a/hedera-node/infrastructure/docker/containers/production-next/consensus-node/Dockerfile +++ b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/Dockerfile @@ -238,9 +238,13 @@ COPY sdk/data/lib/* /opt/hgcapp/services-hedera/HapiApp2.0/data/lib/ # Add the entrypoint script ADD entrypoint.sh /opt/hgcapp/services-hedera/HapiApp2.0/ +# Add s6-rc configuration +COPY etc/s6-overlay/s6-rc.d /etc/s6-overlay/s6-rc.d/ + # Ensure proper file permissions RUN chmod -R +x /opt/hgcapp/services-hedera/HapiApp2.0/entrypoint.sh && \ - chown -R 2000:2000 /opt/hgcapp/services-hedera/HapiApp2.0 + chown -R 2000:2000 /opt/hgcapp/services-hedera/HapiApp2.0 && \ + chmod -R +x /etc/s6-overlay/s6-rc.d/hedera ######################################## #### Deterministic Build Hack #### @@ -275,6 +279,9 @@ ENV MALLOC_ARENA_MAX 4 # Log Folder Name Override ENV LOG_DIR_NAME "" +# Customize s6-overlay +ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME 0 + # Define Volume Bindpoints VOLUME "/opt/hgcapp/accountBalances" VOLUME "/opt/hgcapp/eventsStreams" @@ -294,4 +301,3 @@ EXPOSE 50111/tcp 50211/tcp 50212/tcp USER 2000 WORKDIR "/opt/hgcapp" ENTRYPOINT ["/init"] -CMD ["/opt/hgcapp/services-hedera/HapiApp2.0/entrypoint.sh"] diff --git a/hedera-node/infrastructure/docker/containers/production-next/consensus-node/entrypoint.sh b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/entrypoint.sh index 6f92d8794d10..23f973b8729f 100644 --- a/hedera-node/infrastructure/docker/containers/production-next/consensus-node/entrypoint.sh +++ b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/entrypoint.sh @@ -31,7 +31,7 @@ function waitForFile() { [[ -z "${fileName}" ]] && return 1 for (( attempts = 0; attempts < 20; attempts++ )); do if [[ -f "${fileName}" ]]; then - size="$(stat -f '+%z' "${fileName}")" + size="$(stat --format '%s' "${fileName}")" [[ -n "${size}" && "${size}" -gt 0 ]] && return 0 fi sleep 6 diff --git a/hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/dependencies.d/base b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/dependencies.d/base new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/type b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/type new file mode 100644 index 000000000000..bdd22a1850ae --- /dev/null +++ b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/type @@ -0,0 +1 @@ +oneshot diff --git a/hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/up b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/up new file mode 100644 index 000000000000..6078f363276e --- /dev/null +++ b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/hedera/up.sh diff --git a/hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/up.sh b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/up.sh new file mode 100644 index 000000000000..8a2a1a6e2414 --- /dev/null +++ b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/hedera/up.sh @@ -0,0 +1,5 @@ +#! /usr/bin/env bash + +/opt/hgcapp/services-hedera/HapiApp2.0/entrypoint.sh +echo ${?} | tee --output-error=warn /run/s6-linux-init-container-results/exitcode > /dev/null +exit 0 diff --git a/hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/user/contents.d/hedera b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/etc/s6-overlay/s6-rc.d/user/contents.d/hedera new file mode 100644 index 000000000000..e69de29bb2d1