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
+19 -8
View File
@@ -14,17 +14,22 @@ import (
"yms-daemon/internal/filestore"
)
// DirectNativeJAR is one JAR supplied directly by Jenkins or an operator.
// FileName is treated as opaque text; no version is parsed from it.
// DirectNativeJAR 表示由 Jenkins 或运维人员直接提供的一个原生后端 JAR 文件。
// FileName 被当作不透明文本处理,不会从中解析任何版本信息。
type DirectNativeJAR struct {
Path string
SHA256 string
// Path JAR 文件的绝对路径。
Path string
// SHA256 JAR 文件的十六进制 SHA-256 摘要。
SHA256 string
// FileName JAR 文件的基础文件名(不含目录)。
FileName string
// Identity JAR 文件的不可变身份(大小与 SHA-256),用于事务校验。
Identity filestore.Identity
}
// OpenDirectNativeJAR validates the direct file, verifies every ZIP entry and
// records the immutable identity used by the transaction.
// OpenDirectNativeJAR 校验直接提供的 JAR 文件:确认其为干净绝对路径下的直接
// 普通文件、文件名以 ".jar" 结尾,并打开验证 ZIP 内所有条目可完整读取,
// 最后记录事务所需的不可变身份。任一校验失败返回错误。
func OpenDirectNativeJAR(jarPath string) (DirectNativeJAR, error) {
if err := validateAbsoluteRegularFile(jarPath, "native backend JAR"); err != nil {
return DirectNativeJAR{}, err
@@ -48,8 +53,10 @@ func OpenDirectNativeJAR(jarPath string) (DirectNativeJAR, error) {
}, nil
}
// CopyArtifact copies the exact JAR into transaction storage and rejects a
// source file that changes after OpenDirectNativeJAR returns.
// CopyArtifact 将 JAR 原样复制到事务存储的 destination,并拒绝在
// OpenDirectNativeJAR 返回之后内容发生变化的源文件。destination 必须是干净
// 绝对路径;复制过程先写临时文件,边复制边计算摘要,比对大小与 SHA-256 一致后
// 对临时副本再次校验 ZIP,最后原子重命名并同步父目录。任一步失败均清理临时文件。
func (j DirectNativeJAR) CopyArtifact(destination string) error {
if !filepath.IsAbs(destination) || filepath.Clean(destination) != destination {
return errors.New("native backend JAR destination must be a clean absolute path")
@@ -111,6 +118,8 @@ func (j DirectNativeJAR) CopyArtifact(destination string) error {
return syncDirectory(parent)
}
// verifyJARArchive 打开 jarPath 对应的 ZIP 并逐条目完整读取(丢弃内容),
// 确认归档结构有效且每个非目录条目可解压。空归档或任一读取失败均返回错误。
func verifyJARArchive(jarPath string) error {
archive, err := zip.OpenReader(jarPath)
if err != nil {
@@ -137,6 +146,8 @@ func verifyJARArchive(jarPath string) error {
return nil
}
// identifyFile 计算指定文件的大小与 SHA-256 摘要,返回不可变身份 Identity。
// 读取或关闭失败时返回错误。
func identifyFile(filePath string) (filestore.Identity, error) {
file, err := os.Open(filePath)
if err != nil {