Skip to content

Commit

Permalink
fix: Add log that worker has crashed (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemaitre-aneo authored Apr 19, 2024
2 parents 0291c25 + 06a49f8 commit f739b9c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Worker/src/DLLWorker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ 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
RUN groupadd --gid 5000 armonikuser && useradd --home-dir /home/armonikuser --create-home --uid 5000 --gid 5000 --shell /bin/sh --skel /dev/null armonikuser
RUN mkdir /cache && chown armonikuser: /cache
USER armonikuser

ENTRYPOINT ["dotnet", "ArmoniK.DevelopmentKit.Worker.DLLWorker.dll"]
ENTRYPOINT ["/entry.sh", "dotnet", "ArmoniK.DevelopmentKit.Worker.DLLWorker.dll"]
21 changes: 21 additions & 0 deletions Worker/src/DLLWorker/entry.sh
Original file line number Diff line number Diff line change
@@ -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" != 0 ]; then
echo "$@" "CRASHED with status code $ret" >&2
fi

# Forward the status code
exit "$ret"

0 comments on commit f739b9c

Please sign in to comment.