Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x11vnc: autorestart and logging #54

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
) &
Loading