Document AutoDL deploy path; harden its token/log handling

Add a section 0 to DEPLOY.md/DEPLOY_ZH.md covering the AutoDL one-click
path (supervisord, not systemd), which was previously only self-documented
in scripts/deploy_autodl.sh.

deploy_autodl.sh:
- --log-dir (default ~/autodl-tmp, the persistent data disk) so the service
  log no longer lands in /tmp, which AutoDL wipes on container reset.
- Re-running without --token now REUSES an existing token instead of
  deleting it, so tweaking an unrelated knob can't silently disable auth;
  add --open to explicitly run without auth.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 04:19:10 +00:00
parent dc4badd0e0
commit 755e5fda44
3 changed files with 139 additions and 12 deletions
+57
View File
@@ -9,6 +9,63 @@ deployment (the default); GPU notes are called out where relevant.
The service entry point is `app.py` (`uvicorn app:app`). See [README.md](README.md)
for the API contract and algorithm details.
Sections 1–12 below are the **manual CPU deploy** (systemd + nginx, the default).
If you are deploying to an **AutoDL GPU box**, the one-click script in section 0 is
faster; the two are independent deployment paths.
---
## 0. Fast path: AutoDL one-click deploy (GPU)
On an AutoDL GPU instance, use the repo's bundled one-click script instead of the
manual dependency install / systemd setup:
```bash
# Assumes the repo is already checked out on the instance (the script does NOT
# git pull); use the server-edition branch.
cd /root/BGfilter-server # your actual path
scripts/deploy_autodl.sh --token <TOKEN>
```
The script **idempotently** installs deps + fetches model weights + installs the
CuPy wheel matching the CUDA version (GPU foreground compositing) + starts a
**supervisord** instance (crash auto-restart) + adds an interactive-login
autostart to `~/.bashrc`, then launches the service and verifies `/healthz`.
Arguments:
| Argument | Default | Meaning |
| --- | --- | --- |
| `--token <TOKEN>` | none | Auth token; sets/updates the `X-Genarrative-Image-Token` requirement. **Omitting it reuses an existing token** (re-running to tweak another knob won't drop auth); only a first run with no token starts OPEN. |
| `--open` | — | Explicitly remove the token and run OPEN (no auth). |
| `--port <PORT>` | `6006` | In-container listen port (matches the AutoDL public port mapping). |
| `--config <cfg>` | `configs/gpu.yaml` | Pipeline config. |
| `--log-dir <dir>` | `~/autodl-tmp` | Directory for the service log `bgfilter.log`. Defaults to the AutoDL persistent data disk `~/autodl-tmp` (survives container resets, unlike `/tmp`). |
**Assumes**: repo already checked out (no `git pull`), root user, torch/CUDA
provided by the AutoDL image, python at `/root/miniconda3`.
**Two AutoDL-inherent gotchas** (the script can't fix these):
- The **public URL mapping** (e.g. `6006 → https://...:8443`) is set in the
**AutoDL web console**, not by this script.
- **After a container restart** the service does not come back on its own — AutoDL
has no systemd / boot hook, so the autostart lives in `~/.bashrc` and only fires
when you open an **interactive shell (SSH / JupyterLab terminal)**.
Talking to supervisord (socket at `~/bgfilter-supervisor.sock`, config at
`~/supervisord.conf`):
```bash
/root/miniconda3/bin/supervisorctl -c ~/supervisord.conf status bgfilter # status
/root/miniconda3/bin/supervisorctl -c ~/supervisord.conf restart bgfilter # restart
tail -f ~/autodl-tmp/bgfilter.log # logs (default ~/autodl-tmp)
```
> After editing `configs/*.yaml` (e.g. enabling `cross_check.reuse_as_seg`), run
> the `restart bgfilter` above so the service reloads config — config is read only
> at startup; there is no per-request switch for it.
---
## 1. Prerequisites