fix: add environment variable exports to startup scripts

- Added MOMENTRY_OUTPUT_DIR, DATABASE_SCHEMA, MOMENTRY_REDIS_PREFIX exports
- Created run-worker-3002.sh for standalone worker
- Created config/ directory with environment-specific files
- Updated AGENTS.md with critical variables section and release checklist

This fixes Python subprocess environment variable inheritance issue
where store_traced_faces.py was using wrong output directory.
This commit is contained in:
Accusys
2026-06-21 21:21:32 +08:00
parent e949ac793d
commit 97180aa7cd
6 changed files with 177 additions and 0 deletions

View File

@@ -407,6 +407,40 @@ cargo run --features player --bin momentry_player -- -o
- `MOMENTRY_PYTHON_PATH` - Python path (default: `/opt/homebrew/bin/python3.11`)
- `MOMENTRY_SCRIPTS_DIR` - Scripts directory
### Critical Variables for Startup Scripts
**IMPORTANT**: Startup scripts must explicitly `export` these variables for Python subprocess inheritance.
#### Production (3002)
Required exports in `run-server-3002.sh` and `run-worker-3002.sh`:
```bash
export MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output
export DATABASE_SCHEMA=public
export MOMENTRY_REDIS_PREFIX=momentry:
export MOMENTRY_SERVER_PORT=3002
```
#### Playground (3003)
Required exports in `run-server-3003.sh`:
```bash
export DATABASE_SCHEMA=dev
export MOMENTRY_SERVER_PORT=3003
export MOMENTRY_REDIS_PREFIX=momentry_dev:
export MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output_dev
```
#### Why This Matters
- Rust process loads `.env` via `dotenv`
- Python subprocess inherits environment from Rust process
- Without explicit `export`, dotenv variables are only available inside Rust
- Python scripts like `store_traced_faces.py` will use hardcoded defaults if not exported
#### Config Directory
Environment-specific configuration files:
- `config/production.env` - Production-specific variables
- `config/development.env` - Development-specific variables
- `config/test.env` - Test environment (if needed)
### Processor Timeouts
- `MOMENTRY_ASR_TIMEOUT` - ASR timeout in seconds (default: 3600)
- `MOMENTRY_CUT_TIMEOUT` - CUT timeout in seconds (default: 3600)
@@ -625,6 +659,16 @@ git push origin main
pg_dump -U accusys -d momentry --schema-only > "$RELEASE_DIR/schema_v0.X.X.sql"
```
5. **驗證環境變數配置**
- ✅ Startup scripts export all required environment variables
- ✅ Python scripts don't use hardcoded paths
- ✅ Environment variables consistent across:
- `.env` / `.env.development`
- Startup script `export`
- Python script `os.environ.get()`
- ✅ Config directory has environment-specific files
- ✅ AGENTS.md documents all required exports
### 重要性
- 避免 release binary 與 current source code 不一致
- 方便追蹤特定 release 的程式碼狀態