adding sys.go and using /x/sys/unix for killing pomme, because syscall package is deprecated. Added small wrapper for killPomme().

This commit is contained in:
grumbulon 2023-02-05 14:23:45 -05:00 committed by Gitea
parent 25229f9c81
commit b8d4af58c8
4 changed files with 17 additions and 5 deletions

2
go.mod
View file

@ -53,7 +53,7 @@ require (
github.com/swaggo/http-swagger v1.3.3
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/sys v0.4.0
golang.org/x/tools v0.1.12 // indirect
gopkg.in/yaml.v3 v3.0.1
modernc.org/libc v1.21.5 // indirect

2
go.sum
View file

@ -185,8 +185,6 @@ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.3 h1:WL2ifUmzR/SLp85CSURAfybcHnGZ+yLSGSxgYXlFBHg=
gorm.io/gorm v1.24.3/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.5 h1:g6OPREKqqlWq4kh/3MCQbZKImeB9e6Xgc4zD+JgNZGE=
gorm.io/gorm v1.24.5/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=

View file

@ -4,7 +4,6 @@ import (
"context"
"fmt"
"net/http"
"syscall"
"time"
"git.freecumextremist.com/grumbulon/pomme/internal"
@ -35,7 +34,7 @@ func setDBMiddleware(next http.Handler) http.Handler {
if err != nil && !ok {
logHandler(genericResponseFields{"error": err.Error(), "message": "Error initializing DB"})
err = syscall.Kill(syscall.Getpid(), syscall.SIGINT)
err = internal.SysKill()
if err != nil {
panic("idk what to do with this but syscall.Kill errored out.")
}

15
internal/sys.go Normal file
View file

@ -0,0 +1,15 @@
package internal
import "golang.org/x/sys/unix"
func SysKill() (err error) {
err = killPomme()
return
}
func killPomme() (err error) {
err = unix.Kill(unix.Getpid(), unix.SIGINT)
return
}