Merge pull request 'Move Python Worker ownership into Infra' (#6) from chore/migrate-python-worker-to-infra into main
Reviewed-on: http://localhost:13000/slh/infra/pulls/6 Reviewed-by: slh <spenguin725@gmail.com>
This commit is contained in:
commit
9af1b171d9
4
.gitignore
vendored
4
.gitignore
vendored
@ -19,3 +19,7 @@ git-bridge/state/
|
|||||||
litellm/.env
|
litellm/.env
|
||||||
mem0/.env
|
mem0/.env
|
||||||
mem0/history/
|
mem0/history/
|
||||||
|
python_worker/app/
|
||||||
|
python_worker/runtime.env
|
||||||
|
python_worker/.migration-state
|
||||||
|
python_worker/.staged-from-n8n
|
||||||
|
|||||||
@ -195,6 +195,38 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- git_forge
|
- git_forge
|
||||||
|
|
||||||
|
python_worker:
|
||||||
|
container_name: python_worker
|
||||||
|
image: n8n-python_worker
|
||||||
|
pull_policy: never
|
||||||
|
restart: unless-stopped
|
||||||
|
stop_grace_period: 60s
|
||||||
|
working_dir: /app
|
||||||
|
env_file:
|
||||||
|
- ./python_worker/runtime.env
|
||||||
|
volumes:
|
||||||
|
- ./python_worker/app:/app
|
||||||
|
- /volume2/docker/n8n/files:/files
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -lc
|
||||||
|
- . /app/.venv/bin/activate && exec python -m uvicorn fastapi_app:app --host 0.0.0.0 --port 8000 --log-level debug
|
||||||
|
dns:
|
||||||
|
- 223.5.5.5
|
||||||
|
- 114.114.114.114
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "/app/.venv/bin/python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=3).read()"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 18
|
||||||
|
start_period: 30s
|
||||||
|
networks:
|
||||||
|
n8n_backbone:
|
||||||
|
aliases:
|
||||||
|
- python_worker
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
git_forge:
|
git_forge:
|
||||||
name: git_forge
|
name: git_forge
|
||||||
@ -202,6 +234,10 @@ networks:
|
|||||||
external: true
|
external: true
|
||||||
name: n8n_default
|
name: n8n_default
|
||||||
|
|
||||||
|
n8n_backbone:
|
||||||
|
external: true
|
||||||
|
name: n8n_default
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
postgres_superuser_password:
|
postgres_superuser_password:
|
||||||
file: ./postgres/secrets/postgres_superuser_password
|
file: ./postgres/secrets/postgres_superuser_password
|
||||||
|
|||||||
28
python_worker/README.md
Normal file
28
python_worker/README.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Python Worker
|
||||||
|
|
||||||
|
`python_worker` 是 n8n、OGame Agent 与其他自动化流程共同使用的 FastAPI
|
||||||
|
服务。本次迁移只调整运行归属和宿主机目录,不重构业务接口。
|
||||||
|
|
||||||
|
## 目录边界
|
||||||
|
|
||||||
|
- `app/`:从 `/volume2/docker/n8n/python_worker` 分两阶段同步的应用、虚拟
|
||||||
|
环境和运行状态,不纳入 Git。
|
||||||
|
- `runtime.env`:从旧容器提取的宿主机运行参数,权限必须为 `0600`,不包含
|
||||||
|
模型或平台凭据,不纳入 Git。
|
||||||
|
- `.migration-state`:切换成功后写入的回滚定位信息,不纳入 Git。
|
||||||
|
- `README.md`:唯一纳入 Gitea 的目录说明。
|
||||||
|
|
||||||
|
容器继续使用 `python_worker` 名称、8000 端口和 `n8n_default` 网络,因此现有
|
||||||
|
n8n 工作流及 OGame Agent 仍通过 `http://python_worker:8000` 访问,不需要修改
|
||||||
|
调用地址。`/files` 仍是 n8n 与 Worker 共用的数据目录,本阶段不迁移。
|
||||||
|
|
||||||
|
## 迁移策略
|
||||||
|
|
||||||
|
迁移前先在旧 Worker 在线时把约 921 MB 的目录预复制到
|
||||||
|
`/volume2/docker/infra/python_worker/app`。正式切换时停止旧容器,再执行一次
|
||||||
|
增量同步,随后由 Infra Compose 启动新容器。旧目录和停止状态的旧容器都会
|
||||||
|
保留,以便回滚。
|
||||||
|
|
||||||
|
当前沿用本地镜像 `n8n-python_worker` 和已有 `.venv`,这是降低首次迁移风险的
|
||||||
|
过渡方案。后续必须单独补充固定版本的生产 Dockerfile,停止容器启动时联网安装
|
||||||
|
依赖,再将该服务纳入可复现构建。
|
||||||
Loading…
x
Reference in New Issue
Block a user