np_app/README.md
Lihatoo cbbef10e5d Prepare persistent v4.5 deployment
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-12 17:31:15 +08:00

61 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# NP Replica
This project provides a local Chinese web replica of the core NUPACK `analysis/input` workflow.
## Run
```bash
docker compose up --build -d
```
Open `http://127.0.0.1:18765`.
## Reverse Proxy
The service listens on port `18765`. You can later reverse proxy `np.lihato.icu` to this port from your public server.
## Endpoints
- `GET /`
- `GET /health`
- `GET /api/example`
- `POST /api/analyze`
- `POST /api/jobs`
- `GET /api/jobs/<job_id>`
## Persistent Shares
Shared result links are stored in Redis when `NP_REDIS_URL` is enabled. The compose file maps Redis data to `./runtime/redis` and enables AOF/RDB persistence, so shares survive container recreation and service restarts. Back up or migrate `./runtime/redis` if you move the deployment.
## Notes
- `tube` mode supports strand concentrations and `SetSpec(max_size=...)`.
- `complex` mode supports explicit complex definitions such as `A+B`.
- Pair matrices are returned as a preview block to keep responses manageable.
- The Docker image compiles ViennaRNA `RNAplot` from `rna/ViennaRNA-2.7.2.tar.gz` and embeds SVG structure plots into MFE results.
- Multistrand MFE plots now use a split-strand layout by default when a structure contains `+`, with `RNAplot` retained as the fallback path.
- The web UI now supports Chinese and English switching, browser-side history, result export, and async polling for submitted jobs.
- Docker now starts three services: `np-replica`, `np-worker`, and `redis`.
- Async jobs use Redis-backed storage and queueing when `NP_REDIS_URL` is configured; otherwise the app falls back to the older in-memory mode.
- The browser-facing API and page behavior stay the same after enabling Redis-backed jobs.
- Worker concurrency is controlled by `NP_WORKER_CONCURRENCY` and defaults to `2`.
- Per-job native thread usage is capped by `NP_PER_JOB_THREAD_LIMIT` and defaults to `1` to prevent a single analysis from monopolizing the machine.
- `NP_STRUCTURE_PLOT_MODE` supports `auto` (default), `split`, and `rnaplot`.
- Static pages are served with ETag-based browser caching; JSON API responses remain uncached.
- The force-directed structure viewer lazy-loads D3 only when that view is opened, so the initial page load is not blocked by the external CDN.
- `/health` uses Redis queue length plus a running-job set instead of scanning every historical job on each poll.
现在 `docker-compose.yml` 面向 64 核 / 64G WSL 服务器的并发策略是:
- 最多同时跑 16 个任务
- 每个任务最多用 4 个计算线程
- 后续任务进入队列等待
- 理论上最多占用约 64 个 native 计算线程,避免 16 × 8 这类过度超卖
如果后面你发现机器还会被压满,最直接的调法就是在 docker-compose.yml 里继续压:
- 把 NP_WORKER_CONCURRENCY 改小
- 或保持并发不变,把 NP_PER_JOB_THREAD_LIMIT 改成 2 或 1