C: handler for abort (#135)

* C: handler for abort

CEF will kill the thread if the GPU process cannot be created. This
brings down Suwayomi with it, so instead just kill the thread and inform
Java about the exception.

* Two-stage build to download an build catch_abort

Building JNI extensions requires JDK, but we don't need it at runtime,
so create a build-step based on JDK, then copy the built binary over

* Add catch handler to github action
This commit is contained in:
Constantin Piber
2025-06-21 18:29:59 +02:00
committed by GitHub
parent eb9e13a432
commit 5aa35914a5
3 changed files with 24 additions and 0 deletions

View File

@@ -183,6 +183,7 @@ jobs:
TACHIDESK_DOCKER_GIT_COMMIT=${{ steps.get_latest_release_metadata.outputs.tachidesk_docker_git_commit }}
TACHIDESK_KCEF=
TACHIDESK_KCEF_RELEASE_URL=https://api.github.com/repos/JetBrains/JetBrainsRuntime/releases/latest
TACHIDESK_ABORT_HANDLER_DOWNLOAD_URL=https://raw.githubusercontent.com/Suwayomi/Suwayomi-Server/refs/heads/master/scripts/resources/catch_abort.c
tags: |
${{ inputs.tachidesk_release_type == 'stable' && 'ghcr.io/suwayomi/tachidesk:latest' || '' }}
ghcr.io/suwayomi/tachidesk:${{ inputs.tachidesk_release_type }}

View File

@@ -1,3 +1,20 @@
FROM eclipse-temurin:21.0.7_6-jdk-noble AS build
ARG TACHIDESK_ABORT_HANDLER_DOWNLOAD_URL
# build abort handler
RUN if [ -n "$TACHIDESK_ABORT_HANDLER_DOWNLOAD_URL" ]; then \
cd /tmp && \
curl "$TACHIDESK_ABORT_HANDLER_DOWNLOAD_URL" -O && \
apt-get update && \
apt-get -y install gcc && \
gcc -fPIC -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -shared catch_abort.c -lpthread -o /opt/catch_abort.so && \
rm -f catch_abort.c && \
apt-get -y purge gcc --auto-remove && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* || exit 1; \
fi
FROM eclipse-temurin:21.0.7_6-jre-noble
ARG BUILD_DATE
@@ -50,6 +67,8 @@ RUN if [ "$TACHIDESK_KCEF" = "y" ] || ([ "$TACHIDESK_KCEF" = "" ] && ([ "$TARGET
rm -rf /var/lib/apt/lists/* || exit 1; \
fi
COPY --from=build /opt/*.so /opt/
# Create a user to run as
RUN userdel -r ubuntu
RUN groupadd --gid 1000 suwayomi && \

View File

@@ -111,4 +111,8 @@ if command -v Xvfb >/dev/null; then
else
echo "Suwayomi built without KCEF support, not starting Xvfb"
fi
if [ -f /opt/catch_abort.so ]; then
export LD_PRELOAD="/opt/catch_abort.so $LD_PRELOAD"
fi
echo "LD_PRELOAD=$LD_PRELOAD"
exec java -Duser.home=/home/suwayomi -jar "/home/suwayomi/startup/tachidesk_latest.jar";