Skip to content

Commit

Permalink
feat(server): kill -9 is not recommand, syscall.Kill SIGTERM instead …
Browse files Browse the repository at this point in the history
…of. (#107)

GREAT Thx for the PR
  • Loading branch information
Lensual authored Jul 25, 2024
1 parent 0d0538a commit 7822afd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/internal/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os/exec"
"strconv"
"strings"
"syscall"
"time"

"github.com/gogf/gf/container/gmap"
Expand Down Expand Up @@ -71,10 +72,9 @@ func (w *Worker) start(req *StartReq) (err error) {
func (w *Worker) stop(requestId string, channelName string) (err error) {
slog.Info("Worker stop start", "channelName", channelName, "requestId", requestId, logTag)

shell := fmt.Sprintf("kill -9 %d", w.Pid)
output, err := exec.Command("sh", "-c", shell).CombinedOutput()
err = syscall.Kill(w.Pid, syscall.SIGTERM)
if err != nil {
slog.Error("Worker kill failed", "err", err, "output", output, "channelName", channelName, "worker", w, "requestId", requestId, logTag)
slog.Error("Worker kill failed", "err", err, "channelName", channelName, "worker", w, "requestId", requestId, logTag)
return
}

Expand Down

0 comments on commit 7822afd

Please sign in to comment.