summaryrefslogtreecommitdiff
path: root/internal/cli/stop/command.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2022-05-31 15:31:39 +0200
committerValery Piashchynski <[email protected]>2022-05-31 15:31:39 +0200
commit01b7dd6fb5a8c63dc3e0f4c5444c859c3266c97d (patch)
tree1b711bcb13fbc350807cd43a5b752e1f3b0815f1 /internal/cli/stop/command.go
parent467e427bf67bffe3dd0df41842dad797b93f56f9 (diff)
add force stop
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'internal/cli/stop/command.go')
-rw-r--r--internal/cli/stop/command.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/internal/cli/stop/command.go b/internal/cli/stop/command.go
index 8b4b589f..533f11d6 100644
--- a/internal/cli/stop/command.go
+++ b/internal/cli/stop/command.go
@@ -5,6 +5,7 @@ import (
"os"
"strconv"
"syscall"
+ "time"
"github.com/roadrunner-server/errors"
"github.com/spf13/cobra"
@@ -16,7 +17,7 @@ const (
)
// NewCommand creates `serve` command.
-func NewCommand(silent *bool) *cobra.Command {
+func NewCommand(silent *bool, force *bool) *cobra.Command {
return &cobra.Command{
Use: "stop",
Short: "Stop RoadRunner server",
@@ -47,6 +48,15 @@ func NewCommand(silent *bool) *cobra.Command {
return errors.E(op, err)
}
+ if *force {
+ // RR may lost the signal if we immediately send it
+ time.Sleep(time.Second)
+ err = process.Signal(syscall.SIGTERM)
+ if err != nil {
+ return errors.E(op, err)
+ }
+ }
+
return nil
},
}