refactor: use nginx -s reload instead of systemd

- doc: add comment
This commit is contained in:
2026-08-17 10:10:14 +08:00
parent 79f18fcdea
commit f536987a7e
62 changed files with 2216 additions and 598 deletions
+13
View File
@@ -7,6 +7,8 @@ import (
"yms-daemon/internal/transaction"
)
// gatewaySwitchIntent 构造原生后端 Nginx 上游切换步骤的意图,记录切换前、
// 切换后各自的端口与配置摘要,供审计与回放时确认两侧快照一致。
func gatewaySwitchIntent(request persistedRequest, before hostnginx.Snapshot, after hostnginx.Snapshot) transaction.StepIntent {
return stepIntent("backend.gateway.switch", "switch host Nginx backend upstream", struct {
BeforePort int `json:"beforePort"`
@@ -16,6 +18,8 @@ func gatewaySwitchIntent(request persistedRequest, before hostnginx.Snapshot, af
}{before.ActivePort, snapshotDigest(before), after.ActivePort, snapshotDigest(after)})
}
// activeLinkIntent 构造替换原生后端兼容性链接步骤的意图,记录链接路径、
// 更新前状态以及即将指向的安装路径。
func activeLinkIntent(request persistedRequest, installedPath string) transaction.StepIntent {
return stepIntent("backend.native.active-link", "replace backend compatibility link", struct {
Path string `json:"path"`
@@ -24,12 +28,15 @@ func activeLinkIntent(request persistedRequest, installedPath string) transactio
}{request.ActiveJARPath, request.ActiveJARBefore, installedPath})
}
// stopPreviousUnitIntent 构造停止前一原生后端单元的步骤意图,记录待停止单元名。
func stopPreviousUnitIntent(request persistedRequest) transaction.StepIntent {
return stepIntent("backend.previous-unit.stop", "stop previous backend unit after drain", struct {
Unit string `json:"unit"`
}{request.PreviousUnit})
}
// activeLinkRestoreIntent 构造恢复原生后端兼容性链接步骤的意图,记录链接
// 路径及其更新前状态,供补偿流程回滚。
func activeLinkRestoreIntent(request persistedRequest) transaction.StepIntent {
return stepIntent("backend.native.active-link.restore", "restore backend compatibility path", struct {
Path string `json:"path"`
@@ -37,18 +44,22 @@ func activeLinkRestoreIntent(request persistedRequest) transaction.StepIntent {
}{request.ActiveJARPath, request.ActiveJARBefore})
}
// gatewayRestoreIntent 构造恢复原生后端 Nginx 上游步骤的意图,记录需恢复到的端口。
func gatewayRestoreIntent(request persistedRequest) transaction.StepIntent {
return stepIntent("backend.gateway.restore", "restore host Nginx backend upstream", struct {
Port int `json:"port"`
}{request.PreviousGatewayPort})
}
// stopTargetUnitIntent 构造停止被补偿的原生后端目标单元步骤的意图,记录待停止单元名。
func stopTargetUnitIntent(request persistedRequest) transaction.StepIntent {
return stepIntent("backend.target-unit.stop", "stop compensated backend target unit", struct {
Unit string `json:"unit"`
}{request.TargetUnit})
}
// restoreTargetSlotIntent 构造恢复被补偿的原生后端目标槽位步骤的意图,记录
// 槽位链接路径、其安装路径以及更新前的链接目标。
func restoreTargetSlotIntent(request persistedRequest, installedPath string) transaction.StepIntent {
return stepIntent("backend.target-slot.restore", "restore compensated backend target slot", struct {
Path string `json:"path"`
@@ -57,6 +68,8 @@ func restoreTargetSlotIntent(request persistedRequest, installedPath string) tra
}{request.TargetSlotJAR, installedPath, request.PreviousSlotTarget})
}
// stepIntent 以键名、显示名和任意值构造一个事务步骤意图。意图值会被序列化为
// JSON;若序列化失败则直接 panic,因为该失败属于程序缺陷而非运行期错误。
func stepIntent(key string, name string, value any) transaction.StepIntent {
content, err := json.Marshal(value)
if err != nil {