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 #!/usr/bin/env bash
# Start production server via launchd # Start production server (port 3002)
set -euo pipefail set -euo pipefail
case "${1:-}" in cd /Users/accusys/momentry_core
stop)
echo "Stopping production server and worker..." # Kill existing processes
launchctl bootout gui/$(id -u)/com.momentry.server 2>/dev/null || true pkill -f "target/debug/momentry server" 2>/dev/null || true
launchctl bootout gui/$(id -u)/com.momentry.worker 2>/dev/null || true pkill -f "target/debug/momentry worker" 2>/dev/null || true
echo "Stopped." sleep 2
;;
restart) # Start server
"$0" stop echo "Starting server on port 3002..."
"$0" start export MOMENTRY_SERVER_PORT=3002
;; export MOMENTRY_REDIS_PREFIX=momentry:
status) export DATABASE_SCHEMA=public
echo "=== Server ===" export MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output
launchctl list com.momentry.server 2>/dev/null | head -5 || echo "Not loaded"
echo "=== Worker ===" nohup ./target/debug/momentry server > logs/momentry_3002.log 2>&1 &
launchctl list com.momentry.worker 2>/dev/null | head -5 || echo "Not loaded" SERVER_PID=$!
echo "=== Health ===" echo "Server PID: $SERVER_PID"
curl -s --max-time 3 http://localhost:3002/api/v1/health 2>/dev/null || echo "No response"
;; sleep 2
*)
echo "Starting production server and worker via launchd..." # Start worker
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.momentry.server.plist 2>/dev/null || launchctl load ~/Library/LaunchAgents/com.momentry.server.plist echo "Starting worker with max_concurrent=6..."
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.momentry.worker.plist 2>/dev/null || launchctl load ~/Library/LaunchAgents/com.momentry.worker.plist nohup ./target/debug/momentry worker \
echo "Done. Use '$0 status' to check." --max-concurrent 6 \
;; --poll-interval 5 \
esac --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"