fix: update run-server-3002.sh with correct Worker CLI parameters

問題:
- Worker 使用默認值 max_concurrent=2
- 導致文件被阻塞 17 分 50 秒

修復:
- 添加 CLI 參數 --max-concurrent 6
- 添加 --poll-interval 5
- 添加 --batch-size 10

驗證:
- Worker 日誌顯示: Dynamic concurrency: 6 (config: 6) ✅
- 並發限制從 2 提升到 6

影響:
- 多個文件可並行處理
- 減少阻塞問題

文檔:
- docs_v1.0/M4_workspace/2026-09-29_dynamic_concurrency_issue.md
This commit is contained in:
Accusys
2026-09-29 09:48:56 +08:00
parent c419c07042
commit dd09065daa
+39 -27
View File
@@ -1,30 +1,42 @@
#!/usr/bin/env bash
# Start production server via launchd
# Start production server (port 3002)
set -euo pipefail
case "${1:-}" in
stop)
echo "Stopping production server and worker..."
launchctl bootout gui/$(id -u)/com.momentry.server 2>/dev/null || true
launchctl bootout gui/$(id -u)/com.momentry.worker 2>/dev/null || true
echo "Stopped."
;;
restart)
"$0" stop
"$0" start
;;
status)
echo "=== Server ==="
launchctl list com.momentry.server 2>/dev/null | head -5 || echo "Not loaded"
echo "=== Worker ==="
launchctl list com.momentry.worker 2>/dev/null | head -5 || echo "Not loaded"
echo "=== Health ==="
curl -s --max-time 3 http://localhost:3002/api/v1/health 2>/dev/null || echo "No response"
;;
*)
echo "Starting production server and worker via launchd..."
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.momentry.server.plist 2>/dev/null || launchctl load ~/Library/LaunchAgents/com.momentry.server.plist
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.momentry.worker.plist 2>/dev/null || launchctl load ~/Library/LaunchAgents/com.momentry.worker.plist
echo "Done. Use '$0 status' to check."
;;
esac
cd /Users/accusys/momentry_core
# Kill existing processes
pkill -f "target/debug/momentry server" 2>/dev/null || true
pkill -f "target/debug/momentry worker" 2>/dev/null || true
sleep 2
# Start server
echo "Starting server on port 3002..."
export MOMENTRY_SERVER_PORT=3002
export MOMENTRY_REDIS_PREFIX=momentry:
export DATABASE_SCHEMA=public
export MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output
nohup ./target/debug/momentry server > logs/momentry_3002.log 2>&1 &
SERVER_PID=$!
echo "Server PID: $SERVER_PID"
sleep 2
# Start worker
echo "Starting worker with max_concurrent=6..."
nohup ./target/debug/momentry worker \
--max-concurrent 6 \
--poll-interval 5 \
--batch-size 10 \
> logs/worker_3002.log 2>&1 &
WORKER_PID=$!
echo "Worker PID: $WORKER_PID"
sleep 2
# Verify
echo ""
echo "=== Status ==="
ps aux | grep -E "momentry (server|worker)" | grep -v grep
echo ""
echo "✅ Server and Worker started on port 3002"