1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-30 19:22:09 +00:00

Moved suicide code out to platform specific files

This commit is contained in:
Ansis 2025-09-11 17:56:11 +02:00
parent 3dd167d770
commit 216129b6b6
3 changed files with 21 additions and 2 deletions

View file

@ -9,7 +9,6 @@ import (
"net/http"
"strconv"
"strings"
"syscall"
"time"
"github.com/julienschmidt/httprouter"
@ -25,7 +24,7 @@ const (
var fatal = func(logger logrus.FieldLogger, err error) {
logger.Errorf("unrecoverable error in the cache: %v", err)
if err := syscall.Kill(syscall.Getpid(), syscall.SIGTERM); err != nil {
if err := suicide(); err != nil {
logger.Errorf("unrecoverable error in the cache: failed to send the TERM signal to shutdown the daemon %v", err)
}
}

View file

@ -0,0 +1,7 @@
package artifactcache
import "syscall"
func suicide() error {
return syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
}

View file

@ -0,0 +1,13 @@
package artifactcache
import "syscall"
func suicide() error {
handle, err := syscall.GetCurrentProcess()
if err != nil {
return err
}
return syscall.TerminateProcess(handle, uint32(syscall.SIGTERM))
}