fix: 规范层约定应用与模块的关系(应用=唯一部署单元,模块不独立部署)
- project-directory-spec:应用是唯一部署单元(一入口一端口),模块不是独立部署单元
- web-application-spec:业务模块通过 load_{module}() 导入应用
- module-development-spec:模块不是独立部署单元(无 app.py/端口)
- design 角色技能:应遵守规范加 web-application-spec + module-development-spec
- deploy_test 角色技能:部署应用单入口,不是各模块各起服务
This commit is contained in:
parent
7b3e474b4d
commit
bde08ea889
@ -20,6 +20,7 @@ This skill defines the complete workflow for standardized modules: ahserver ecos
|
||||
- A module is a self-contained unit ANY host can load (pipeline-app / sage / future apps). It depends ONLY on: ① foundation packages (sqlor, ahserver ServerEnv, appPublic utilities); ② its own data tables (or shared tables like sage's appcodes); ③ other modules it explicitly imports.
|
||||
- It does NOT depend on any host entry point, host-specific config files, or host wwwroot paths.
|
||||
- `load_{module}()` is the ONLY integration point — it registers functions to ServerEnv; the host decides how to wire it in.
|
||||
- **A module is NOT an independently deployable unit.** It has NO standalone `app.py` entry point, NO own port, NO own Dockerfile/service, NO own deploy script. It only runs because a host application calls `load_{module}()`. A module that carries its own `app.py` / port / deploy script is wrongly built — fix the module, don't deploy it separately.
|
||||
- **Interaction-layer modules** (e.g. pipeline-task) have NO data tables — pure thin wrappers calling other modules' functions via ServerEnv; they provide .dspy + .ui only.
|
||||
|
||||
## Directory Structure
|
||||
|
||||
@ -73,11 +73,13 @@ global(全局基础)→ org(客户)→ pipeline(产线)→ project
|
||||
- 存放一个应用的代码(可运行、可部署的应用单元)。
|
||||
- 一个应用一个仓库,命名 `{应用名}_app`,一个项目可有多个应用。
|
||||
- 有远程 git 仓库。
|
||||
- **应用是唯一部署单元**:一个应用 = 一个入口(`app/{应用名}.py`)= 一个端口。业务模块通过 `load_{module}()` 挂到应用这个唯一入口下,模块不独立部署、不独立占端口。
|
||||
|
||||
### {模块名} —— 独立模块仓库
|
||||
- 存放一个独立模块的代码(可复用单元,含自己的数据 / CRUD / 处理逻辑 / skills)。
|
||||
- 一个模块一个仓库,命名 `{模块名}`(无后缀),由 design 阶段划分。
|
||||
- 有远程 git 仓库。
|
||||
- **模块不是独立部署单元**:模块是应用内的功能模块(Python 包),无独立 app.py / 端口,必须通过 `load_{module}()` 挂到应用才能运行。
|
||||
- 内部结构以 `module-development-spec` 技能为准(Python 包目录=模块名 + wwwroot/models/json/init/scripts/skill/pyproject.toml),本规范不重复定义。
|
||||
|
||||
## 四、命名规范
|
||||
|
||||
@ -79,10 +79,18 @@ def init():
|
||||
load_rbac()
|
||||
load_pybricks()
|
||||
|
||||
# ── 业务模块导入(关键:一个应用一个入口一个端口,所有模块挂在这里)──
|
||||
from organization.init import load_organization
|
||||
from payroll.init import load_payroll
|
||||
load_organization()
|
||||
load_payroll()
|
||||
|
||||
if __name__ == '__main__':
|
||||
webapp(init)
|
||||
```
|
||||
|
||||
> **业务模块如何导入到应用(关键)**:一个应用 = 一个入口(`app/${appname}.py`)= 一个端口。业务模块(organization/payroll/recruitment/...)是 Python 包,通过各自的 `load_{module}()` 在 `init()` 里逐个加载,**挂在应用这个唯一入口下**。不要给每个模块单独建 `app.py`、单独占端口、单独起服务——模块不是独立部署单元,应用才是。
|
||||
|
||||
### conf/config.json (Configuration)
|
||||
Must include the following sections:
|
||||
- `password_key`: System encryption key
|
||||
|
||||
@ -25,12 +25,12 @@ capability: deploy_capability
|
||||
- **禁止写占位符**(`[已写入磁盘]`、`<粘贴实际输出>`)或假装部署完成
|
||||
|
||||
### 二、真实执行部署(SSH 到测试机,Python 直跑,不是写文档)
|
||||
1. `scp -r` 各模块代码到 `hrs@hrstest.opencomputing.cn:~/hrs_app/`
|
||||
1. `scp -r` 应用代码(`{应用名}_app`)+ 各模块(Python 包)到 `hrs@hrstest.opencomputing.cn:~/hrs_app/`
|
||||
2. `ssh hrs@hrstest.opencomputing.cn` 执行真实部署:
|
||||
- 建表:`mysql -h localhost -u test -ptest123 hrs < {模块}/ddl/*.sql`
|
||||
- 装依赖:`pip3 install -r requirements.txt`(或 `pip3 install -e {模块}`)
|
||||
- 起服务:`nohup python3 app.py` 后台启动各模块(端口互不冲突,写 PID)
|
||||
3. 每个模块都要能启动;缺 app.py 的模块,用统一方式启动(或 `ask_question` 冒泡让 develop 补 app.py)
|
||||
- 装依赖:`pip3 install -e {模块}`(模块是 Python 包,pip 安装)
|
||||
- 起服务:`nohup python3 app/{应用名}.py` 启动**应用**(唯一入口、唯一端口,应用内 `load_{module}()` 加载各模块)
|
||||
3. **部署的是应用(一个入口一个端口),不是每个模块各起一个服务**——模块无独立 app.py/端口,挂在应用下运行。缺应用入口或模块挂载的,`ask_question` 冒泡让 develop 补。
|
||||
|
||||
### 三、部署后验证(附真实输出,不是预期声明)
|
||||
- **检查进程**:`ssh hrs@hrstest "ps -ef | grep app.py"` 各模块进程确实在跑
|
||||
|
||||
@ -13,7 +13,9 @@ capability: task_capability
|
||||
- 基础模块(apppublic/sqlor/ahserver/accounting/appbase/rbac)已存在,不列为待开发模块
|
||||
|
||||
## 应遵守的规范(设计前先 load_skill 加载对应全文,不要凭记忆瞎写)
|
||||
- `project-directory-spec`:项目目录结构 + 设计文档落点路径(repos/{项目名}_pc/docs/01-design/、modules/)
|
||||
- `project-directory-spec`:项目目录结构 + 设计文档落点路径(repos/{项目名}_pc/docs/01-design/、modules/)+ 应用与模块的关系(应用=唯一部署单元,模块不独立部署)
|
||||
- `sdlc-repo-standard`:设计交付件的内容格式(templates/module-design.md、templates/module-skill.md)
|
||||
- `web-application-spec`:应用规范(应用结构、应用如何通过 load_{module}() 导入模块、一个入口一个端口)
|
||||
- `module-development-spec`:模块规范(模块是 Host-Agnostic Python 包、不是独立部署单元,无独立 app.py/端口)
|
||||
- `database-design`:数据库设计规范(字段语义→类型映射、系统不加外键、编码字典设计,设计阶段产出时遵守)
|
||||
- `database-table-definition-spec`:表定义四段式格式
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user