Add the svc.sh environment service manager #45

Merged
weichen merged 4 commits from feature/svc-env-script into main 2026-09-30 11:38:57 +00:00
Owner

feature/svc-env-script:环境服务管理脚本

scripts/svc.sh dev|prod [deploy|stop|start|restart|status|logs];make svc ENV=... 快捷入口。

  • deploy = 停止本环境旧服务 → make build(前端+内嵌后端)→ 启动 + 健康检查
  • dev/prod 完全隔离:runtime//{data,pid,log,env};默认 8788/8787,SVC_* 可覆盖(含 prod PG DSN)
  • 安全:只停 pidfile+cmdline 双验的自己的进程;端口被他方占用时拒接并点名占用者
  • 实测矩阵:部署全链/重部署保数据/双环境并存数据隔离/端口冲突拒接/停止释放端口
# feature/svc-env-script:环境服务管理脚本 scripts/svc.sh dev|prod [deploy|stop|start|restart|status|logs];make svc ENV=... 快捷入口。 - deploy = 停止本环境旧服务 → make build(前端+内嵌后端)→ 启动 + 健康检查 - dev/prod 完全隔离:runtime/<env>/{data,pid,log,env};默认 8788/8787,SVC_* 可覆盖(含 prod PG DSN) - 安全:只停 pidfile+cmdline 双验的自己的进程;端口被他方占用时拒接并点名占用者 - 实测矩阵:部署全链/重部署保数据/双环境并存数据隔离/端口冲突拒接/停止释放端口
weichen added 4 commits 2026-09-30 11:38:57 +00:00
Why: deploying a new build meant manually finding and killing the old
process, rebuilding and re-launching with the right flags; dev and prod
instances could collide on ports, data dirs or kill each other.

Evidence: live matrix on the worktree - dev deploy (stop -> make build
-> start with health check), redeploy swaps the pid and keeps seeded
data, prod deploys alongside dev on separate port/data with fully
isolated /api/projects, port takeover is refused with the owning
process named while the running env stays up, stop clears pidfile and
frees the port. A pid-capture bug (compound-background subshell wrote
the wrapper pid instead of the server) was caught and fixed during the
first live run.

Impact: scripts/svc.sh <dev|prod> [deploy|stop|start|restart|status|
logs]; runtime/<env>/{data,svc.pid,svc.log,svc.env} isolation; defaults
dev 127.0.0.1:8788 / prod 127.0.0.1:8787 overridable via SVC_* env
vars (incl. SVC_PROD_DSN for the PG tier); make svc ENV=... shortcut;
runtime/ gitignored. Safety: only processes started by the script are
stopped (pidfile + /proc cmdline double check).

Refs: feature/svc-env-script task card.
Record the sync checkpoint
ci / test (pull_request) Failing after 1m31s
c1eea4b05b
weichen merged commit 5b81f82120 into main 2026-09-30 11:38:57 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-System-Dev#45