This repository has been archived on 2026-10-25. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Arvex c439732832 feat: v0.1 - recursive file browser, syntax highlighting, dynamic projects, search, save feedback
- Recursive directory browsing with breadcrumb navigation
- highlight.js syntax highlighting for code files (JS, JSON, CSS, HTML, Python, YAML, Bash, Markdown)
- Dynamic projects tab parsing PROJECTS.md from workspace
- Save feedback with success/error indicators
- Dark theme support for text editor
- File search filter on workspace tab
- Android watchdog script for auto-restart
- EADDRINUSE retry for Android socket TIME_WAIT
- Fix nested file save paths (was dropping directory components)
- Fix Shoelace component init with Alpine.js x-if
- Default port changed to 3001
2026-04-04 13:40:41 -06:00

49 lines
1.2 KiB
Bash

#!/data/data/com.termux/files/usr/bin/bash
# SmallClawViewer watchdog — restarts the server if port 3001 is dead
APP_DIR="/data/data/com.termux/files/home/.openclaw/workspace/SmallClawViewer"
LOG="$APP_DIR/watchdog.log"
PIDFILE="$APP_DIR/.server.pid"
PORT=3001
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG"
}
start_server() {
log "Starting SmallClawViewer on port $PORT..."
cd "$APP_DIR" || exit 1
node server/index.js &
echo $! > "$PIDFILE"
# Wait longer for it to actually bind (handles EADDRINUSE retries)
for i in 1 2 3 4 5 6 7 8; do
if fuser "$PORT/tcp" >/dev/null 2>&1; then
log "Server bound to port $PORT (PID $(cat $PIDFILE 2>/dev/null))"
return 0
fi
sleep 2
done
log "WARNING: Server may have failed to start"
return 1
}
log "Watchdog started"
log "Monitoring port $PORT every 60s"
# Initial start if not running
if ! fuser "$PORT/tcp" >/dev/null 2>&1; then
start_server
else
log "Port $PORT already in use, nothing to do"
fi
while true; do
if ! fuser "$PORT/tcp" >/dev/null 2>&1; then
log "Port $PORT is dead, restarting..."
kill $(cat "$PIDFILE" 2>/dev/null) 2>/dev/null
sleep 3
start_server
fi
sleep 60
done