Files
kandev/apps/backend/internal/agentctl/client/launcher/platform_unix.go
T
2026-03-02 16:11:13 +00:00

26 lines
582 B
Go

//go:build !windows
package launcher
import (
"syscall"
"go.uber.org/zap"
)
// gracefulStop sends SIGTERM to the process for graceful shutdown.
// Falls back to SIGKILL if SIGTERM fails.
func (l *Launcher) gracefulStop(pid int) error {
if err := syscall.Kill(pid, syscall.SIGTERM); err != nil {
l.logger.Warn("failed to send SIGTERM, trying SIGKILL", zap.Error(err))
_ = syscall.Kill(pid, syscall.SIGKILL)
return err
}
return nil
}
// forceKill sends SIGKILL to the agentctl process.
func (l *Launcher) forceKill(pid int) {
_ = syscall.Kill(pid, syscall.SIGKILL)
}