summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorGhost Walker <[email protected]>2023-09-10 14:27:16 +0300
committerGhost Walker <[email protected]>2023-09-10 14:27:16 +0300
commit21c51152c424a2a860f3803cef8f39bb0b300576 (patch)
tree5040911324235085f62ebcbd9a2845938fd3926a /internal
parent51a4bf5412bd832079a72f98271b2eefb6148be2 (diff)
Update root.go
Diffstat (limited to 'internal')
-rw-r--r--internal/cli/root.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/internal/cli/root.go b/internal/cli/root.go
index 145d9404..3f69e807 100644
--- a/internal/cli/root.go
+++ b/internal/cli/root.go
@@ -1,12 +1,8 @@
package cli
import (
+ "context"
"fmt"
- "os"
- "path/filepath"
- "runtime"
- "strconv"
-
"github.com/joho/godotenv"
"github.com/roadrunner-server/errors"
"github.com/roadrunner-server/roadrunner/v2023/internal/cli/jobs"
@@ -17,6 +13,12 @@ import (
dbg "github.com/roadrunner-server/roadrunner/v2023/internal/debug"
"github.com/roadrunner-server/roadrunner/v2023/internal/meta"
"github.com/spf13/cobra"
+ "os"
+ "os/signal"
+ "path/filepath"
+ "runtime"
+ "strconv"
+ "syscall"
)
const (
@@ -90,7 +92,14 @@ func NewCommand(cmdName string) *cobra.Command { //nolint:funlen,gocognit
if debug {
srv := dbg.NewServer()
- go func() { _ = srv.Start(":6061") }() // TODO implement graceful server stopping
+ go func() {
+ exit := make(chan os.Signal, 1)
+ signal.Notify(exit, os.Interrupt, syscall.SIGTERM, syscall.SIGINT, syscall.SIGABRT)
+ go srv.Start(":6061")
+
+ <-exit
+ _ = srv.Stop(context.Background())
+ }()
}
// user wanted to write a .pid file