#!/bin/bash # 启动 Receipt Printer 服务器并监控 PIDFILE="/tmp/receipt-printer.pid" LOGFILE="/home/ching/.openclaw/workspace/receipt-printer/server.log" cd /home/ching/.openclaw/workspace/receipt-printer # 如果已有进程在运行,先停止 if [ -f "$PIDFILE" ]; then OLD_PID=$(cat "$PIDFILE" 2>/dev/null) if kill -0 "$OLD_PID" 2>/dev/null; then echo "Stopping existing server (PID: $OLD_PID)..." kill "$OLD_PID" sleep 2 fi fi # 清理旧日志 > "$LOGFILE" # 启动服务器 bun run src/server.ts >> "$LOGFILE" 2>&1 & echo $! > "$PIDFILE" echo "Receipt Printer Server started with PID: $!" echo "Log file: $LOGFILE" echo "Test: curl http://localhost:3000/health"