chore: organize logs into logs/ directory with startup scripts

- Moved momentry_3002.log, momentry_3003.log to logs/
- Moved 34 nohup_worker_*.log files to logs/
- Created run-server-3002.sh, run-server-3003.sh for easy startup
- Updated AGENTS.md with log paths and startup scripts
- logs/ already excluded by *.log in .gitignore
This commit is contained in:
Accusys
2026-05-20 09:31:48 +08:00
parent 8b53e815b8
commit 8ede4be159
3 changed files with 81 additions and 0 deletions

View File

@@ -32,6 +32,16 @@ Rust-based digital asset management system with video analysis and RAG capabilit
| Production | 3002 | ❌ 禁止修改 | `cargo run -- server` (僅 release 時) | | Production | 3002 | ❌ 禁止修改 | `cargo run -- server` (僅 release 時) |
| Portal (Tauri) | 1420 | 前端開發 | `npm run tauri dev` | | Portal (Tauri) | 1420 | 前端開發 | `npm run tauri dev` |
### 日誌與啟動
| 服務 | 日誌路徑 | 啟動方式 |
|------|----------|----------|
| Production (3002) | `logs/momentry_3002.log` | `./run-server-3002.sh` |
| Playground (3003) | `logs/momentry_3003.log` | `./run-server-3003.sh` |
| Worker / 歷史 | `logs/nohup_worker_*.log` | 由 worker 自動產生 |
> **注意**: 所有伺服器日誌統一存放於專案內 `logs/` 目錄。
> 啟動腳本會自動 kill 舊程序、重 build若需要、並將日誌導向 `logs/`。
## ⚠️ 交叉污染防制 (Cross-Contamination Prevention) ## ⚠️ 交叉污染防制 (Cross-Contamination Prevention)
**每個執行前必須評估是否會汙染其他獨立作業。** **每個執行前必須評估是否會汙染其他獨立作業。**
@@ -192,6 +202,21 @@ cargo run -- server --host 0.0.0.0 --port 3002
# Run playground (development binary) # Run playground (development binary)
cargo run --bin momentry_playground -- server cargo run --bin momentry_playground -- server
cargo run --bin momentry_playground -- --help cargo run --bin momentry_playground -- --help
# Start servers (recommended — auto-build & logs to logs/)
./run-server-3002.sh
./run-server-3003.sh
```
### Server Logs
All runtime logs are centralized in `logs/`:
```bash
# View real-time logs
tail -f logs/momentry_3002.log
tail -f logs/momentry_3003.log
# Check recent errors
grep -i "error\|panic\|FAIL" logs/momentry_*.log | tail -20
``` ```
### ⚠️ CRITICAL: `cargo build --release` PROHIBITION ### ⚠️ CRITICAL: `cargo build --release` PROHIBITION

28
run-server-3002.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Start production server on port 3002
# Logs to logs/momentry_3002.log
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Kill existing server on port 3002
PID=$(lsof -ti :3002 2>/dev/null || true)
if [ -n "$PID" ]; then
echo "Killing existing server on port 3002 (PID: $PID)"
kill "$PID" 2>/dev/null || true
sleep 2
fi
# Build if needed
if [ ! -f target/release/momentry ]; then
echo "Building release binary..."
cargo build --release --bin momentry
fi
# Start server
echo "Starting momentry server on port 3002..."
./target/release/momentry server --host 0.0.0.0 --port 3002 > logs/momentry_3002.log 2>&1 &
echo "Server started (PID: $!)"
echo "Logs: logs/momentry_3002.log"

28
run-server-3003.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Start playground server on port 3003
# Logs to logs/momentry_3003.log
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Kill existing server on port 3003
PID=$(lsof -ti :3003 2>/dev/null || true)
if [ -n "$PID" ]; then
echo "Killing existing server on port 3003 (PID: $PID)"
kill "$PID" 2>/dev/null || true
sleep 2
fi
# Build if needed
if [ ! -f target/debug/momentry_playground ]; then
echo "Building playground binary..."
cargo build --bin momentry_playground
fi
# Start server
echo "Starting momentry_playground server on port 3003..."
./target/debug/momentry_playground server --port 3003 > logs/momentry_3003.log 2>&1 &
echo "Server started (PID: $!)"
echo "Logs: logs/momentry_3003.log"