tao-shen Claude Opus 4.6 commited on
Commit
7da6a48
Β·
1 Parent(s): 7e6866f

feat: detailed system boot logs (kernel, CPU, mem, disk, services)

Browse files

start-server.sh now outputs:
- System info: kernel, arch, CPU, memory, disk
- Network interfaces
- Each service start with [OK]/[FAILED] status
- Service summary table (PIDs + ports)
- Package counts (base vs current)
- Full process listing
- All output to stderr for HF runtime logs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. ubuntu-server/start-server.sh +54 -12
ubuntu-server/start-server.sh CHANGED
@@ -1,19 +1,31 @@
1
  #!/bin/bash
2
  # ─────────────────────────────────────────────────────────────────────
3
- # HuggingRun Ubuntu Server: ttyd + SSH-over-WebSocket
4
  # Port 7860 (nginx): web terminal + SSH
5
- #
6
- # Persistence is handled by git_sync_daemon.py (started in entrypoint)
7
- # This script just starts the services.
8
  # ─────────────────────────────────────────────────────────────────────
9
- echo "[start-server] Starting services ..." >&2
10
 
11
  export SSH_PORT="${SSH_PORT:-2222}"
12
  export TTYD_PORT="${TTYD_PORT:-7681}"
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  # ── sshd ──────────────────────────────────────────────────────────
15
  mkdir -p /run/sshd
16
- echo "[start-server] Starting sshd on 127.0.0.1:$SSH_PORT ..." >&2
17
  /usr/sbin/sshd -o "Port=$SSH_PORT" \
18
  -o "ListenAddress=127.0.0.1" \
19
  -o "PermitRootLogin=yes" \
@@ -23,22 +35,52 @@ echo "[start-server] Starting sshd on 127.0.0.1:$SSH_PORT ..." >&2
23
  -D -e &
24
  SSHD_PID=$!
25
  sleep 1
26
- echo "[start-server] sshd PID=$SSHD_PID" >&2
 
 
 
 
27
 
28
  # ── WebSocket-to-SSH bridge ──────────────────────────────────────
29
- echo "[start-server] Starting WS-SSH bridge on 127.0.0.1:7862 ..." >&2
30
  python3 /opt/ws-ssh-bridge.py &
31
  BRIDGE_PID=$!
32
  sleep 1
33
- echo "[start-server] WS-SSH bridge PID=$BRIDGE_PID" >&2
 
 
 
 
34
 
35
  # ── ttyd (web terminal) ─────────────────────────────────────────
36
- echo "[start-server] Starting ttyd on 127.0.0.1:$TTYD_PORT ..." >&2
37
  ttyd --port "$TTYD_PORT" --writable --base-path / bash --login &
38
  TTYD_PID=$!
39
  sleep 1
40
- echo "[start-server] ttyd PID=$TTYD_PID" >&2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  # ── nginx (foreground, port 7860) ────────────────────────────────
43
- echo "[start-server] Starting nginx on 0.0.0.0:7860 ..." >&2
 
44
  exec nginx -g 'daemon off;'
 
1
  #!/bin/bash
2
  # ─────────────────────────────────────────────────────────────────────
3
+ # HuggingRun Ubuntu Server: ttyd + SSH-over-WebSocket + nginx
4
  # Port 7860 (nginx): web terminal + SSH
 
 
 
5
  # ─────────────────────────────────────────────────────────────────────
 
6
 
7
  export SSH_PORT="${SSH_PORT:-2222}"
8
  export TTYD_PORT="${TTYD_PORT:-7681}"
9
 
10
+ echo "========================================" >&2
11
+ echo "[ubuntu] HuggingRun Ubuntu Server" >&2
12
+ echo "[ubuntu] $(date -u)" >&2
13
+ echo "[ubuntu] Kernel: $(uname -r)" >&2
14
+ echo "[ubuntu] Arch: $(uname -m)" >&2
15
+ echo "[ubuntu] Hostname: $(hostname)" >&2
16
+ echo "[ubuntu] CPU: $(nproc) cores" >&2
17
+ echo "[ubuntu] Memory: $(free -h 2>/dev/null | awk '/Mem:/{print $2}' || echo 'unknown')" >&2
18
+ echo "[ubuntu] Disk: $(df -h / 2>/dev/null | awk 'NR==2{print $2, "total,", $4, "free"}' || echo 'unknown')" >&2
19
+ echo "[ubuntu] User: $(whoami) (uid=$(id -u))" >&2
20
+ echo "========================================" >&2
21
+
22
+ # ── Network info ───────────────────────────────────────────────────
23
+ echo "[ubuntu] Network interfaces:" >&2
24
+ ip -4 addr show 2>/dev/null | grep -E 'inet |^[0-9]' | sed 's/^/ /' >&2 || true
25
+
26
  # ── sshd ──────────────────────────────────────────────────────────
27
  mkdir -p /run/sshd
28
+ echo "[ubuntu] Starting sshd on 127.0.0.1:${SSH_PORT} ..." >&2
29
  /usr/sbin/sshd -o "Port=$SSH_PORT" \
30
  -o "ListenAddress=127.0.0.1" \
31
  -o "PermitRootLogin=yes" \
 
35
  -D -e &
36
  SSHD_PID=$!
37
  sleep 1
38
+ if kill -0 $SSHD_PID 2>/dev/null; then
39
+ echo "[ubuntu] [ OK ] sshd started (PID=${SSHD_PID})" >&2
40
+ else
41
+ echo "[ubuntu] [FAILED] sshd failed to start" >&2
42
+ fi
43
 
44
  # ── WebSocket-to-SSH bridge ──────────────────────────────────────
45
+ echo "[ubuntu] Starting WS-SSH bridge on 127.0.0.1:7862 ..." >&2
46
  python3 /opt/ws-ssh-bridge.py &
47
  BRIDGE_PID=$!
48
  sleep 1
49
+ if kill -0 $BRIDGE_PID 2>/dev/null; then
50
+ echo "[ubuntu] [ OK ] WS-SSH bridge started (PID=${BRIDGE_PID})" >&2
51
+ else
52
+ echo "[ubuntu] [FAILED] WS-SSH bridge failed to start" >&2
53
+ fi
54
 
55
  # ── ttyd (web terminal) ─────────────────────────────────────────
56
+ echo "[ubuntu] Starting ttyd on 127.0.0.1:${TTYD_PORT} ..." >&2
57
  ttyd --port "$TTYD_PORT" --writable --base-path / bash --login &
58
  TTYD_PID=$!
59
  sleep 1
60
+ if kill -0 $TTYD_PID 2>/dev/null; then
61
+ echo "[ubuntu] [ OK ] ttyd started (PID=${TTYD_PID})" >&2
62
+ else
63
+ echo "[ubuntu] [FAILED] ttyd failed to start" >&2
64
+ fi
65
+
66
+ # ── Process summary ──────────────────────────────────────────────
67
+ echo "========================================" >&2
68
+ echo "[ubuntu] Services:" >&2
69
+ echo "[ubuntu] sshd PID=${SSHD_PID} 127.0.0.1:${SSH_PORT}" >&2
70
+ echo "[ubuntu] ws-ssh-bridge PID=${BRIDGE_PID} 127.0.0.1:7862" >&2
71
+ echo "[ubuntu] ttyd PID=${TTYD_PID} 127.0.0.1:${TTYD_PORT}" >&2
72
+ echo "[ubuntu] nginx (foreground) 0.0.0.0:7860" >&2
73
+ echo "========================================" >&2
74
+
75
+ # ── Installed packages ───────────────────────────────────────────
76
+ echo "[ubuntu] Base packages: $(wc -l < /etc/base-packages.list 2>/dev/null || echo '?')" >&2
77
+ echo "[ubuntu] Current packages: $(dpkg-query -W -f='\n' 2>/dev/null | wc -l)" >&2
78
+
79
+ # ── Running processes ────────────────────────────────────────────
80
+ echo "[ubuntu] All processes:" >&2
81
+ ps aux --no-headers 2>/dev/null | awk '{printf "[ubuntu] %-8s PID=%-6s %s\n", $1, $2, $11}' >&2 || true
82
 
83
  # ── nginx (foreground, port 7860) ────────────────────────────────
84
+ echo "[ubuntu] Starting nginx on 0.0.0.0:7860 (foreground) ..." >&2
85
+ echo "[ubuntu] ══ System ready ══" >&2
86
  exec nginx -g 'daemon off;'