Skip to content

Commit

Permalink
x11vnc: autorestart and logging (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
x5a authored Oct 22, 2024
1 parent 6271405 commit 0cd8e73
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions computer-use-demo/image/x11vnc_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ echo "starting vnc"
-rfbport 5900 \
2>/tmp/x11vnc_stderr.log) &

x11vnc_pid=$!

# Wait for x11vnc to start
timeout=10
while [ $timeout -gt 0 ]; do
Expand All @@ -23,9 +25,25 @@ while [ $timeout -gt 0 ]; do
done

if [ $timeout -eq 0 ]; then
echo "x11vnc stderr output:" >&2
echo "x11vnc failed to start, stderr output:" >&2
cat /tmp/x11vnc_stderr.log >&2
exit 1
fi

rm /tmp/x11vnc_stderr.log
: > /tmp/x11vnc_stderr.log

# Monitor x11vnc process in the background
(
while true; do
if ! kill -0 $x11vnc_pid 2>/dev/null; then
echo "x11vnc process crashed, restarting..." >&2
if [ -f /tmp/x11vnc_stderr.log ]; then
echo "x11vnc stderr output:" >&2
cat /tmp/x11vnc_stderr.log >&2
rm /tmp/x11vnc_stderr.log
fi
exec "$0"
fi
sleep 5
done
) &

0 comments on commit 0cd8e73

Please sign in to comment.