fix: загрузка sac-api.env через pydantic, не EnvironmentFile systemd

This commit is contained in:
PTah
2026-05-26 21:07:51 +10:00
parent 539126b75e
commit 934a5a0c9c
4 changed files with 33 additions and 8 deletions
+5 -1
View File
@@ -171,7 +171,10 @@ sudo -u sac bash -c 'set -a; source /opt/security-alert-center/config/sac-api.en
## 8. systemd
Приложение загружает `config/sac-api.env` **само** (не через `EnvironmentFile` systemd) — так же, как при `alembic` с `source`.
```bash
cd /opt/security-alert-center && sudo git pull
sudo cp /opt/security-alert-center/deploy/systemd/sac-api.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable sac-api
@@ -290,7 +293,8 @@ sudo systemctl restart sac-api
| Симптом | Действие |
|---------|----------|
| `sac-api.env: Permission denied` | Конфиг в `/opt/security-alert-center/config/`, `chown sac:sac`, `chmod 600`. Не используйте `/etc/...` с каталогом `root:root` |
| `password authentication failed for user sac` | Пароль в `DATABASE_URL` ≠ пароль в PostgreSQL; или `.env` не прочитан (тогда берётся дефолт `sac:sac`). Исправить пароль: `sudo -u postgres psql -c "ALTER USER sac PASSWORD '...';"` и обновить `DATABASE_URL` |
| `password authentication failed` в **sac-api**, но alembic OK | Старый unit с `EnvironmentFile=``git pull`, обновить `sac-api.service`, `daemon-reload`, `restart`. Либо пароль в `DATABASE_URL` ≠ PostgreSQL |
| `password authentication failed` везде | Пароль в `DATABASE_URL` в кавычках; `ALTER USER sac WITH PASSWORD`; тот же пароль в URL |
| `database: error` / SQLAlchemy connect | `systemctl status postgresql`; проверить `DATABASE_URL` после успешного `source` |
| 401 ingest | ключ в `Authorization: Bearer`; проверить `SAC_BOOTSTRAP_API_KEY` |
| 502 от nginx | API не слушает: `ss -lntp \| grep 8000`, `systemctl restart sac-api` |