fix variable in env

This commit is contained in:
2026-04-28 10:18:44 +07:00
parent f6c5dce452
commit 7cace210d6
7 changed files with 79 additions and 16 deletions
+19 -14
View File
@@ -65,11 +65,11 @@ authInternalUsers:
- action: api
```
Sau đó trên máy chạy dashboard backend:
Sau đó set trong file `.env` của dashboard backend:
```bash
export MEDIAMTX_API_USER="dashboard"
export MEDIAMTX_API_PASS="dashboard_password"
```
MEDIAMTX_API_USER=dashboard
MEDIAMTX_API_PASS=dashboard_password
```
Trong `paths`, bạn có thể để dashboard tự thêm path bằng API (Settings → Add Camera).
@@ -128,7 +128,15 @@ pip install -r api/requirements.txt
### 3.2 Cấu hình
Chạy backend lần đầu sẽ tự tạo `api/data/config.json`.
Tạo file `.env`:
```bash
cp .env.example .env
```
Backend sẽ tự load `.env` khi start.
Chạy backend lần đầu sẽ tự tạo `api/data/config.json` (lưu danh sách camera + schedule).
Bạn có thể chỉnh:
@@ -156,18 +164,16 @@ export MEDIAMTX_WEBRTC_URL="http://192.168.88.10:8889"
export RECORDINGS_DIR="/recordings"
```
Nếu MediaMTX API có auth, export biến môi trường:
Nếu MediaMTX API có auth, set trong `.env`:
```bash
export MEDIAMTX_API_USER="..."
export MEDIAMTX_API_PASS="..."
```
- `MEDIAMTX_API_USER`
- `MEDIAMTX_API_PASS`
### 3.3 Chạy backend
```bash
source api/.venv/bin/activate
uvicorn api.app.main:app --host 0.0.0.0 --port 8008
python3 api/run.py
```
## 4) Frontend (build static)
@@ -228,9 +234,8 @@ After=network.target
[Service]
WorkingDirectory=/opt/ipcam-dashboard
Environment=MEDIAMTX_API_USER=
Environment=MEDIAMTX_API_PASS=
ExecStart=/opt/ipcam-dashboard/api/.venv/bin/uvicorn api.app.main:app --host 0.0.0.0 --port 8008
EnvironmentFile=/opt/ipcam-dashboard/.env
ExecStart=/opt/ipcam-dashboard/api/.venv/bin/python /opt/ipcam-dashboard/api/run.py
Restart=always
RestartSec=2