Fixed container restart

This commit is contained in:
2024-05-13 21:43:21 +02:00
parent 987aaa65a7
commit faae225d96
7 changed files with 78 additions and 13 deletions
+15 -9
View File
@@ -1,11 +1,17 @@
#!/bin/bash
#!/usr/bin/env bash
set -x
export DISPLAY=:${DISPLAY_NUM}
RFB_PORT=59${DISPLAY_NUM}
NOVNC_PORT=80${DISPLAY_NUM}
source /app/signals.sh
echo Display at ${DISPLAY} with ${SCREEN_W}x${SCREEN_H}x24
exec icewm-session -o /var/log/icewm.log &
exec /opt/TurboVNC/bin/Xvnc ${DISPLAY} -geometry ${SCREEN_W}x${SCREEN_H} -depth 24 +xinerama -securitytypes none >/var/log/xvfb.log &
exec socat TCP-LISTEN:60${DISPLAY_NUM},fork,bind=0.0.0.0 UNIX-CONNECT:/tmp/.X11-unix/X${DISPLAY_NUM} &
exec /tmp/websockify/run --web=/tmp/noVNC/ --cert=/tmp/novnc.pem --key=/tmp/novnc.key ${NOVNC_PORT} localhost:${RFB_PORT}
signals_trap_with_arg func_trap TERM
/app/server.sh &
PID=-1
# wait forever
while true
do
tail -f /dev/null & wait ${!}
done
# https://medium.com/@gchudnov/trapping-signals-in-docker-containers-7a57fdda7d86
Executable
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -x
RFB_PORT=59${DISPLAY_NUM}
NOVNC_PORT=80${DISPLAY_NUM}
echo Display at ${DISPLAY} with ${SCREEN_W}x${SCREEN_H}x24
/opt/TurboVNC/bin/Xvnc ${DISPLAY} -geometry ${SCREEN_W}x${SCREEN_H} -depth 24 +xinerama -securitytypes none >/var/log/xvfb.log &
icewm-session -o /var/log/icewm.log &
/tmp/websockify/run -D --web=/tmp/noVNC/ --cert=/tmp/novnc.pem --key=/tmp/novnc.key ${NOVNC_PORT} localhost:${RFB_PORT}
socat TCP-LISTEN:60${DISPLAY_NUM},fork,bind=0.0.0.0 UNIX-CONNECT:/tmp/.X11-unix/X${DISPLAY_NUM}
+21
View File
@@ -0,0 +1,21 @@
PID=0
signals_trap_with_arg() {
func="$1" ; shift
for sig ; do
echo "$func $sig"
trap "$func $sig" "$sig"
done
}
func_trap() {
echo "Trapped: $1"
echo "Killing ${PID}"
if [ ${PID} -ne 0 ]; then
kill -SIGTERM "${PID}"
wait "${PID}"
fi
ps -ef --forest
exit 143
}