Skip to content

Commit 0cd8e73

Browse files
authored
x11vnc: autorestart and logging (#54)
1 parent 6271405 commit 0cd8e73

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

computer-use-demo/image/x11vnc_startup.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ echo "starting vnc"
1212
-rfbport 5900 \
1313
2>/tmp/x11vnc_stderr.log) &
1414

15+
x11vnc_pid=$!
16+
1517
# Wait for x11vnc to start
1618
timeout=10
1719
while [ $timeout -gt 0 ]; do
@@ -23,9 +25,25 @@ while [ $timeout -gt 0 ]; do
2325
done
2426

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

31-
rm /tmp/x11vnc_stderr.log
33+
: > /tmp/x11vnc_stderr.log
34+
35+
# Monitor x11vnc process in the background
36+
(
37+
while true; do
38+
if ! kill -0 $x11vnc_pid 2>/dev/null; then
39+
echo "x11vnc process crashed, restarting..." >&2
40+
if [ -f /tmp/x11vnc_stderr.log ]; then
41+
echo "x11vnc stderr output:" >&2
42+
cat /tmp/x11vnc_stderr.log >&2
43+
rm /tmp/x11vnc_stderr.log
44+
fi
45+
exec "$0"
46+
fi
47+
sleep 5
48+
done
49+
) &

0 commit comments

Comments
 (0)