ci cross-platform fix: make gateway reload/signal handling windows-safe with build-tagged helpers

This commit is contained in:
DBT
2026-03-01 13:15:09 +00:00
parent 09a28836ca
commit 9238dc3c2b
5 changed files with 52 additions and 5 deletions

View File

@@ -11,7 +11,6 @@ import (
"reflect"
"runtime"
"strings"
"syscall"
"time"
"clawgo/pkg/agent"
@@ -203,7 +202,7 @@ func gatewayCmd() {
return out
})
registryServer.SetConfigAfterHook(func() {
_ = syscall.Kill(os.Getpid(), syscall.SIGHUP)
_ = requestGatewayReloadSignal()
})
registryServer.SetCronHandler(func(action string, args map[string]interface{}) (interface{}, error) {
getStr := func(k string) string {
@@ -353,11 +352,11 @@ func gatewayCmd() {
go runGatewayBootstrapInit(ctx, cfg, agentLoop)
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
signal.Notify(sigChan, gatewayNotifySignals()...)
for {
sig := <-sigChan
switch sig {
case syscall.SIGHUP:
switch {
case isGatewayReloadSignal(sig):
fmt.Println("\n↻ Reloading config...")
newCfg, err := config.LoadConfig(getConfigPath())
if err != nil {

12
cmd/clawgo/reload_unix.go Normal file
View File

@@ -0,0 +1,12 @@
//go:build !windows
package main
import (
"os"
"syscall"
)
func requestGatewayReloadSignal() error {
return syscall.Kill(os.Getpid(), syscall.SIGHUP)
}

View File

@@ -0,0 +1,7 @@
//go:build windows
package main
func requestGatewayReloadSignal() error {
return nil
}

View File

@@ -0,0 +1,16 @@
//go:build !windows
package main
import (
"os"
"syscall"
)
func gatewayNotifySignals() []os.Signal {
return []os.Signal{os.Interrupt, syscall.SIGTERM, syscall.SIGHUP}
}
func isGatewayReloadSignal(sig os.Signal) bool {
return sig == syscall.SIGHUP
}

View File

@@ -0,0 +1,13 @@
//go:build windows
package main
import "os"
func gatewayNotifySignals() []os.Signal {
return []os.Signal{os.Interrupt}
}
func isGatewayReloadSignal(sig os.Signal) bool {
return false
}