@runuai/host 0.9.93 → 0.9.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -941,6 +941,15 @@ console.log(
941
941
  * lockfile and PIDFILES — never pgrep: a pgrep -f guard sharing a cmdline
942
942
  * with its own payload self-matches and skips the start (this exact bug
943
943
  * kept the stack down in every container until 2026-07-08).
944
+ *
945
+ * The pidfile tracks the LOOP SHELL, not the port. When a loop is orphaned
946
+ * — the display owner changes, or two ensures race, and the single pidfile
947
+ * only remembers the latest — the previous loop's websockify keeps holding
948
+ * 6080, and SO_REUSEADDR lets the new one bind alongside it. The kernel
949
+ * then round-robins connections across both, so the viewer lands on a live
950
+ * proxy only SOMETIMES and reconnects the rest (live 2026-09-02). So the
951
+ * start branch — reached only when the tracked loop is already dead — first
952
+ * reaps anything still holding the port, guaranteeing exactly one listener.
944
953
  */
945
954
  const VIEWER_STEPS: string[] = [
946
955
  // Xvfb — one-shot; the X lockfile is the truth (also set when an agent
@@ -949,9 +958,9 @@ const VIEWER_STEPS: string[] = [
949
958
  `[ -x /usr/bin/Xvfb ] || exit 0; [ -e ${X_LOCK} ] || /usr/bin/nohup /usr/bin/${XVFB_CMD} >>/tmp/uai-xvfb.log 2>&1 &`,
950
959
  // x11vnc under a restart loop (it exits whenever the X server isn't up
951
960
  // yet). Pidfile-guarded.
952
- `[ -x /usr/bin/x11vnc ] || exit 0; [ -f /tmp/uai-x11vnc.pid ] && /usr/bin/kill -0 "$(/usr/bin/cat /tmp/uai-x11vnc.pid)" 2>/dev/null && exit 0; /usr/bin/nohup /bin/sh -c 'echo $$ > /tmp/uai-x11vnc.pid; while true; do /usr/bin/x11vnc -display ${SERVER_DISPLAY} -forever -shared -nopw -quiet >>/tmp/uai-x11vnc.log 2>&1; /bin/sleep 2; done' >/dev/null 2>&1 &`,
961
+ `[ -x /usr/bin/x11vnc ] || exit 0; [ -f /tmp/uai-x11vnc.pid ] && /usr/bin/kill -0 "$(/usr/bin/cat /tmp/uai-x11vnc.pid)" 2>/dev/null && exit 0; /usr/bin/pkill -f 'x11vnc -display' 2>/dev/null; /usr/bin/nohup /bin/sh -c 'echo $$ > /tmp/uai-x11vnc.pid; while true; do /usr/bin/x11vnc -display ${SERVER_DISPLAY} -forever -shared -nopw -quiet >>/tmp/uai-x11vnc.log 2>&1; /bin/sleep 2; done' >/dev/null 2>&1 &`,
953
962
  // websockify/noVNC under the same pattern.
954
- `[ -x /usr/bin/websockify ] || exit 0; [ -f /tmp/uai-novnc.pid ] && /usr/bin/kill -0 "$(/usr/bin/cat /tmp/uai-novnc.pid)" 2>/dev/null && exit 0; /usr/bin/nohup /bin/sh -c 'echo $$ > /tmp/uai-novnc.pid; while true; do /usr/bin/websockify --web=/usr/share/novnc 0.0.0.0:6080 localhost:5900 >>/tmp/uai-websockify.log 2>&1; /bin/sleep 2; done' >/dev/null 2>&1 &`,
963
+ `[ -x /usr/bin/websockify ] || exit 0; [ -f /tmp/uai-novnc.pid ] && /usr/bin/kill -0 "$(/usr/bin/cat /tmp/uai-novnc.pid)" 2>/dev/null && exit 0; /usr/bin/pkill -f 'websockify.*6080' 2>/dev/null; /usr/bin/nohup /bin/sh -c 'echo $$ > /tmp/uai-novnc.pid; while true; do /usr/bin/websockify --web=/usr/share/novnc 0.0.0.0:6080 localhost:5900 >>/tmp/uai-websockify.log 2>&1; /bin/sleep 2; done' >/dev/null 2>&1 &`,
955
964
  ];
956
965
 
957
966
  const DEFAULT_NODE_BIN =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runuai/host",
3
- "version": "0.9.93",
3
+ "version": "0.9.94",
4
4
  "description": "Uai host — runs ephemeral AI tasks in containers on a machine you control.",
5
5
  "license": "MIT",
6
6
  "author": "Uai Tech <team@runuai.com>",