fix: windows compilation (#1101)
Original pull request: https://code.forgejo.org/forgejo/runner/pulls/987 Fixes https://code.forgejo.org/forgejo/runner/issues/1032 <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - bug fixes - [PR](https://code.forgejo.org/forgejo/runner/pulls/1101): <!--number 1101 --><!--line 0 --><!--description Zml4OiB3aW5kb3dzIGNvbXBpbGF0aW9u-->fix: windows compilation<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1101 Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org> Co-authored-by: volkmnv <volkmnv@noreply.code.forgejo.org> Co-committed-by: volkmnv <volkmnv@noreply.code.forgejo.org>
This commit is contained in:
parent
8a98a8a512
commit
ea961a70c3
3 changed files with 24 additions and 2 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
9
act/artifactcache/utils.go
Normal file
9
act/artifactcache/utils.go
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
//go:build !windows
|
||||
|
||||
package artifactcache
|
||||
|
||||
import "syscall"
|
||||
|
||||
func suicide() error {
|
||||
return syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
|
||||
}
|
||||
14
act/artifactcache/utils_windows.go
Normal file
14
act/artifactcache/utils_windows.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
//go:build windows
|
||||
|
||||
package artifactcache
|
||||
|
||||
import "syscall"
|
||||
|
||||
func suicide() error {
|
||||
handle, err := syscall.GetCurrentProcess()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return syscall.TerminateProcess(handle, uint32(syscall.SIGTERM))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue