From 06590d523812d7e154f0bd400646619bdba1d5fb Mon Sep 17 00:00:00 2001 From: Florian Lemaitre Date: Tue, 16 Apr 2024 08:51:19 +0200 Subject: [PATCH 1/2] Add log that process has crashed --- Worker/src/DLLWorker/Dockerfile | 5 ++++- Worker/src/DLLWorker/entry.sh | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100755 Worker/src/DLLWorker/entry.sh diff --git a/Worker/src/DLLWorker/Dockerfile b/Worker/src/DLLWorker/Dockerfile index 75a03f7e..19dc9229 100644 --- a/Worker/src/DLLWorker/Dockerfile +++ b/Worker/src/DLLWorker/Dockerfile @@ -32,6 +32,9 @@ RUN case "$TARGETARCH" in \ dotnet publish "ArmoniK.DevelopmentKit.Worker.DLLWorker.csproj" -c "${BUILD_CONFIG}" -f net6.0 -o /app/publish -r "${DOTNET_ARCH}" --self-contained true FROM base AS final + +COPY ["Worker/src/DLLWorker/entry.sh", "/entry.sh"] + WORKDIR /app COPY --from=publish /app/publish . ENV LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH @@ -39,4 +42,4 @@ RUN groupadd --gid 5000 armonikuser && useradd --home-dir /home/armonikuser --cr RUN mkdir /cache && chown armonikuser: /cache USER armonikuser -ENTRYPOINT ["dotnet", "ArmoniK.DevelopmentKit.Worker.DLLWorker.dll"] +ENTRYPOINT ["/entry.sh", "dotnet", "ArmoniK.DevelopmentKit.Worker.DLLWorker.dll"] diff --git a/Worker/src/DLLWorker/entry.sh b/Worker/src/DLLWorker/entry.sh new file mode 100755 index 00000000..c9db39de --- /dev/null +++ b/Worker/src/DLLWorker/entry.sh @@ -0,0 +1,21 @@ +#! /bin/sh + +# Enable coredumps +ulimit -c unlimited + +# Rip child processes +trap 'kill -s INT -- -$$' INT +trap 'kill -s TERM -- -$$' TERM + +# Launch command in background to be sure it will be ripped +"$@" & +wait $! +ret="$?" + +# Add log that process has crashed +if [ "$ret" = 139 ]; then + echo "$@" "CRASHED" +fi + +# Forward the status code +exit "$ret" From 06a49f8eaefd07571cb6e4e8674e84cae8208d42 Mon Sep 17 00:00:00 2001 From: lemaitre-aneo Date: Wed, 17 Apr 2024 17:44:14 +0200 Subject: [PATCH 2/2] Add crash log for any error --- Worker/src/DLLWorker/entry.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Worker/src/DLLWorker/entry.sh b/Worker/src/DLLWorker/entry.sh index c9db39de..d461737d 100755 --- a/Worker/src/DLLWorker/entry.sh +++ b/Worker/src/DLLWorker/entry.sh @@ -13,8 +13,8 @@ wait $! ret="$?" # Add log that process has crashed -if [ "$ret" = 139 ]; then - echo "$@" "CRASHED" +if [ "$ret" != 0 ]; then + echo "$@" "CRASHED with status code $ret" >&2 fi # Forward the status code