Why:
svc.sh only managed agent-system environments; databases, standalone
frontend serving, per-service tags and reusable start configs were out of
scope, and the user asked for a unified service lifecycle on this host.
Evidence:
- Service model v2: kind=agent|static|postgres registered in
runtime/<name>/svc.env (dotenv, mode 600); legacy entries without kind=
are adopted as agent.
- postgres: "db create <name> --port/--user/--password/--db/--auth-mode/
--tag" runs initdb (scram-sha-256, pwfile 0600), start/stop/restart use
pg_ctl (-m fast, never SIGKILL on postmaster) with pg_isready checks and
first-start database creation; "db dsn <name> [--reveal]" prints a
composable DSN (password masked by default). Verified end to end against
a real postgresql@18 instance: data survives restart, wrong passwords
rejected, stop/restart clean.
- static: "deploy --kind static --from dev[@sha]|local" builds frontend
dist into htdocs/ in an isolated worktree, or "--dir PATH" serves an
existing directory; verified serving HTTP 200, restart, stop, dry-run
plan, and explicit rejection of release sources.
- agent: unchanged three deploy sources plus --tag; bare start/restart now
reuses the persisted exec= from svc.env (verified: same custom port and
args across restart); old binaries lacking --dsn/--auth get those flags
auto-omitted with a warning.
- "list|status [--tag]" shows NAME/KIND/STATE/PID/ADDR/SOURCE/TAGS for all
registered services; "<name> status" gives per-kind detail; "rm <name>
[--purge]" unregisters (and optionally deletes) only runtime/<name>/.
- Fixed during verification: psql arg mangling (-c -c), tags lost because
record_state read svc.env inside its own redirect block, postgres
--version field parsing, unbound vars for unregistered names.
Impact:
Same invariants as before: writes stay under runtime/<name>/ and
runtime/.worktrees/ (only --from local also writes main-checkout build
outputs, all gitignored), stops only own pidfile+cmdline-verified
processes, port conflicts reported not seized. Prompt output moved to
stderr so stdout (tables, DSNs) stays pipeable. Makefile gains svc-list.
Refs: .task/feature-svc-services-registry.md(任务卡=PR 描述)
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
feature/svc-services-registry 任务卡
任务主记录:<PR 链接,task-finish 时填写>;状态:进行中;owner:weichen
基线与授权
a2657bc25f仅改 Dev 仓
scripts/svc.sh与Makefile,不动模块 gitlink;不碰 Releases 仓与主检出运行现场。目标与非目标
目标(scripts/svc.sh v2 —— 服务模型泛化):
static(前端静态服务:
--from dev@sha|local构建 frontend dist → 环境内 htdocs,或--dir PATH直接服务既有目录);postgres(见 2)。svc.sh db create <name> [--port --host --user --password --db --auth-mode --tag]——initdb(默认 scram-sha-256)到环境目录,
pg_ctl生命周期、pg_isready探活、svc.sh db dsn <name> [--reveal]打印连接串(默认掩码密码);鉴权/端口/用户/密码/库名可配并持久化,供 agent 服务 --dsn 引用。
--config FILE(--env 别名,dotenv)+ CLI 覆盖(优先级:CLI > 配置文件 > 上次启动持久化配置(svc.env exec=) > 默认);
--tag可重复,持久化登记,
list --tag过滤。svc.sh list|status(等价)——全部服务表格:名称/类型/状态/pid/地址/来源(提交或版本)/标签;
svc.sh <name> status单服务详情(版本、数据目录、DSN 等)。pg_ctl stop -m fast(绝不裸杀 postmaster);新增svc.sh rm <name> [--purge](注销登记,--purge 连数据目录一起删,仅限 runtime// 内)。
非目标:不做守护进程/自动拉起/健康巡检(未来可演进二进制);不做 postgres 版本管理
(用系统二进制,版本语义由数据目录+标签承载);static 不做 SPA 路由重写;不管理
容器(全局非容器约束);不动 Releases 仓产物结构。
关键设计决策
进程编排 + 状态文件,bash + /proc + dotenv 足够、零构建依赖;registry 用 dotenv 而非
JSON 保持无 jq 可解析,将来迁二进制可直接沿用文件格式。
增加 kind(agent|postgres|static,缺省 agent 兼容旧登记)、tags、pidcheck、exec(上次
完整启动参数,裸 start/restart 复用)、kind 特有键;事件流 history.jsonl 不变。
cmdline 标记双校验"的进程;端口冲突预检保留;svc.env 含密码 → 600;DSN 默认不回显
密码。
--from local是唯一写主检出构建产物(bin/、node_modules/、dist/,均 gitignore)的路径,显式文档化;dev@sha/release/static 构建完全在隔离 worktree。
psql),
pg_config --bindir可定位;SVC_PG_BIN 可覆盖。同步记录
a2657bc25fa2657bc25f结果与验证(完成后填写)
--config 配置文件(--env 别名)、持久化配置复用(svc.env exec=/addr/...)、list 总览、
db create/dsn、rm [--purge];Makefile 增 svc-list 并更新帮助。历史与登记文件格式不变,
旧登记(无 kind=)自动视为 agent。
指定密码,svc.env 600)→ start(pg_ctl + pg_isready 就绪 + 自动建库)→ psql 写入数据 →
restart 后数据仍在 → 错误密码被拒 → db dsn 掩码/--reveal → stop(pg_ctl fast)→
rm --purge。测试中修复:psql 参数错位(-c -c)、record_state/write_static_reg 在重定向
块内读同文件导致 tags 丢失、postgres --version 字段解析。
release 源明确报"不支持";--dir 不存在报错。
→ 裸 restart 复用 svc.env exec=(同端口同参数)→ list 三类服务混排正确 → status 详情
(版本/标签/来源)→ commits release 标注 [已部署:prod]。
--dsn "$(svc.sh db dsn pg1 --reveal)"传入 agent 部署(0.1.0 旧二进制自动省略 --dsn/--auth 并警告);db dsn stdout 纯净可捕获。
history 支持纯数字首参。
合入的 agent 构建同机制,已验证过);static 深链路由不重写(http.server 行为);
svc 提示信息改走 stderr(stdout 只留数据),脚本管道组合更干净。