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
+4
View File
@@ -1,3 +1,7 @@
// Package processlock 提供服务端进程级排他锁,确保同一时刻只有一个 serve 进程持有内核锁。
//
// 锁基于 Linux advisory flock 实现,具体见 lock_linux.go
// 在非 Linux 平台返回 ErrUnsupported(见 lock_unsupported.go)。
package processlock
import "errors"
+4 -1
View File
@@ -15,7 +15,9 @@ import (
// Lock 持有与文件描述符绑定的 Linux advisory flock。
// 锁文件可以永久存在;只有内核锁状态表示当前所有权。
type Lock struct {
mu sync.Mutex
// mu 保证释放操作与状态访问的并发安全。
mu sync.Mutex
// file 与内核锁绑定的锁文件描述符。
file *os.File
}
@@ -50,6 +52,7 @@ func Acquire(path string) (*Lock, error) {
return &Lock{file: file}, nil
}
// writeOwnerPID 将当前进程 PID 写入锁文件并落盘,供诊断排查。
func writeOwnerPID(file *os.File) error {
if err := file.Truncate(0); err != nil {
return fmt.Errorf("truncate process lock metadata: %w", err)
+2
View File
@@ -9,6 +9,8 @@ import (
"testing"
)
// TestLockUsesKernelOwnershipAndLeavesFileInPlace 验证锁由内核状态决定所有权、
// 锁文件在释放后保留、写入诊断 PID,并可在释放后重新获取。
func TestLockUsesKernelOwnershipAndLeavesFileInPlace(t *testing.T) {
t.Parallel()
path := filepath.Join(t.TempDir(), "serve.lock")