Move storage initialization into the backend executable
This commit is contained in:
+5
-5
@@ -10,11 +10,11 @@ Bedrock reads a YAML deployment file from `BEDROCK_DB_CONFIG`. The loader also a
|
||||
|
||||
## Local SQLite
|
||||
|
||||
Bedrock defaults to `bedrock.sqlite3` in the working directory. To choose another path, set `BEDROCK_DB_CONFIG` to a [SQLite configuration](local/sqlite.yaml) and set the resource's `primary` to a persistent, writable path.
|
||||
Run `backend --init-storage` to initialize storage once. Bedrock defaults to `bedrock.sqlite3` in the working directory. To choose another path, set `BEDROCK_DB_CONFIG` to a [SQLite configuration](local/sqlite.yaml) and set the resource's `primary` to a persistent, writable path.
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
A["在本机启动 Bedrock"] --> B{"是否设置 BEDROCK_DB_CONFIG"}
|
||||
A["在本机运行 backend --init-storage"] --> B{"是否设置 BEDROCK_DB_CONFIG"}
|
||||
B -->|是| C["读取指定的 SQLite 配置,取得文件路径"]
|
||||
B -->|否| D["使用工作目录下的 bedrock.sqlite3"]
|
||||
C --> E["打开或创建 SQLite 文件"]
|
||||
@@ -26,18 +26,18 @@ flowchart TD
|
||||
|
||||
PostgreSQL on the existing host uses Gitea Actions variables `BEDROCK_PG_HOST`, `BEDROCK_PG_PORT`, `BEDROCK_PG_DATABASE`, `BEDROCK_PG_USER` and secret `BEDROCK_PG_PASSWORD`. The release invokes `python3 deploy/gitea/render-postgres.py /path/to/private/bedrock.yaml --deployment production --config-version RELEASE_ID`. The renderer writes a private file. The database must already exist and present a trusted certificate for the selected endpoint.
|
||||
|
||||
Gitea builds a release on `ces-control` when a commit lands on `main`. The deploy step renders the private PostgreSQL configuration and runs the current one-shot Rust storage initializer on the existing `endoleap-dev_default` network. It publishes releases under `/opt/endoleap-infra/bedrock-rust/releases` and switches `/opt/endoleap-infra/bedrock-rust/current` after successful initialization. The Go service retains its own containers and routes.
|
||||
Gitea builds a release on `ces-control` when a commit lands on `main`. The deploy step renders the private PostgreSQL configuration and runs `backend --init-storage` through the published `bedrock` executable on the existing `endoleap-dev_default` network. It publishes releases under `/opt/endoleap-infra/bedrock-rust/releases` and switches `/opt/endoleap-infra/bedrock-rust/current` after successful initialization. The Go service retains its own containers and routes.
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
M["main 收到提交"] --> W["deploy.yml 在 ces-control 上启动"]
|
||||
W --> B["build-release.sh 编译发布版"]
|
||||
W --> B["build-release.sh 编译 backend 发布版"]
|
||||
B -->|Bedrock 二进制和 Git SHA| R
|
||||
E["Gitea PostgreSQL Variables 和 Secret"] -->|部署参数| P
|
||||
|
||||
subgraph release["release.sh"]
|
||||
R["暂存待发布版本"] --> P["调用 render-postgres.py 生成私有 bedrock.yaml"]
|
||||
P -->|配置就绪| I["启动临时容器,由 Bedrock 初始化 PostgreSQL"]
|
||||
P -->|配置就绪| I["临时容器运行 backend 的 --init-storage,初始化 PostgreSQL"]
|
||||
I -->|成功| S["保存版本并原子切换 current"]
|
||||
P -->|失败| F["清理暂存目录,保留现有 current"]
|
||||
I -->|失败| F
|
||||
|
||||
Reference in New Issue
Block a user