Skip to content

Commit 721ffed

Browse files
committed
[force] add force flag on start/stop/restart command
1 parent 15d5f2a commit 721ffed

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

cli/command/restart.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
package command
2626

2727
import (
28+
"fmt"
29+
2830
"github.com/dingodb/curveadm/cli/cli"
2931
"github.com/dingodb/curveadm/internal/configure/topology"
3032
"github.com/dingodb/curveadm/internal/errno"
@@ -41,9 +43,10 @@ var (
4143
)
4244

4345
type restartOptions struct {
44-
id string
45-
role string
46-
host string
46+
id string
47+
role string
48+
host string
49+
force bool
4750
}
4851

4952
func NewRestartCommand(curveadm *cli.CurveAdm) *cobra.Command {
@@ -66,6 +69,7 @@ func NewRestartCommand(curveadm *cli.CurveAdm) *cobra.Command {
6669
flags.StringVar(&options.id, "id", "*", "Specify service id")
6770
flags.StringVar(&options.role, "role", "*", "Specify service role")
6871
flags.StringVar(&options.host, "host", "*", "Specify service host")
72+
flags.BoolVarP(&options.force, "force", "f", false, "Never prompt")
6973

7074
return cmd
7175
}
@@ -106,6 +110,12 @@ func runRestart(curveadm *cli.CurveAdm, options restartOptions) error {
106110
return err
107111
}
108112

113+
// 3) force restart
114+
if options.force {
115+
fmt.Print(tui.PromptRestartService(options.id, options.role, options.host))
116+
return pb.Run()
117+
}
118+
109119
// 3) confirm by user
110120
if pass := tui.ConfirmYes(tui.PromptRestartService(options.id, options.role, options.host)); !pass {
111121
curveadm.WriteOut(tui.PromptCancelOpetation("restart service"))

cli/command/start.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
package command
2626

2727
import (
28+
"fmt"
29+
2830
"github.com/dingodb/curveadm/cli/cli"
2931
"github.com/dingodb/curveadm/internal/configure/topology"
3032
"github.com/dingodb/curveadm/internal/errno"
@@ -41,9 +43,10 @@ var (
4143
)
4244

4345
type startOptions struct {
44-
id string
45-
role string
46-
host string
46+
id string
47+
role string
48+
host string
49+
force bool
4750
}
4851

4952
func checkCommonOptions(curveadm *cli.CurveAdm, id, role, host string) error {
@@ -88,6 +91,7 @@ func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command {
8891
flags.StringVar(&options.id, "id", "*", "Specify service id")
8992
flags.StringVar(&options.role, "role", "*", "Specify service role")
9093
flags.StringVar(&options.host, "host", "*", "Specify service host")
94+
flags.BoolVarP(&options.force, "force", "f", false, "Never prompt")
9195

9296
return cmd
9397
}
@@ -128,6 +132,12 @@ func runStart(curveadm *cli.CurveAdm, options startOptions) error {
128132
return err
129133
}
130134

135+
// 3) force start
136+
if options.force {
137+
fmt.Print(tui.PromptStartService(options.id, options.role, options.host))
138+
return pb.Run()
139+
}
140+
131141
// 3) confirm by user
132142
if pass := tui.ConfirmYes(tui.PromptStartService(options.id, options.role, options.host)); !pass {
133143
curveadm.WriteOut(tui.PromptCancelOpetation("start service"))

cli/command/stop.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
package command
2626

2727
import (
28+
"fmt"
29+
2830
"github.com/dingodb/curveadm/cli/cli"
2931
"github.com/dingodb/curveadm/internal/configure/topology"
3032
"github.com/dingodb/curveadm/internal/errno"
@@ -41,9 +43,10 @@ var (
4143
)
4244

4345
type stopOptions struct {
44-
id string
45-
role string
46-
host string
46+
id string
47+
role string
48+
host string
49+
force bool
4750
}
4851

4952
func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command {
@@ -66,6 +69,7 @@ func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command {
6669
flags.StringVar(&options.id, "id", "*", "Specify service id")
6770
flags.StringVar(&options.role, "role", "*", "Specify service role")
6871
flags.StringVar(&options.host, "host", "*", "Specify service host")
72+
flags.BoolVarP(&options.force, "force", "f", false, "Never prompt")
6973

7074
return cmd
7175
}
@@ -106,6 +110,12 @@ func runStop(curveadm *cli.CurveAdm, options stopOptions) error {
106110
return err
107111
}
108112

113+
// 3) force stop
114+
if options.force {
115+
fmt.Print(tui.PromptStopService(options.id, options.role, options.host))
116+
return pb.Run()
117+
}
118+
109119
// 3) confirm by user
110120
pass := tui.ConfirmYes(tui.PromptStopService(options.id, options.role, options.host))
111121
if !pass {

internal/task/scripts/shell/start_gateway.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env bash
22

3-
# Usage: curve fs gateway --mdsaddr={mdsaddr} --listen-address {listenAddr} --console-address {consoleAddr} --mountpoint {mountPoint}
4-
# Example: curve fs gateway --mdsaddr=172.20.7.232:16700,172.20.7.233:16700,172.20.7.234:16700 --listen-address=:29000 --console-address=:29002 --mountpoint=/home/dingofs/cli/cli1
3+
# Usage: curve gateway --mdsaddr={mdsaddr} --listen-address {listenAddr} --console-address {consoleAddr} --mountpoint {mountPoint}
4+
# Example: curve gateway --mdsaddr=172.20.7.232:16700,172.20.7.233:16700,172.20.7.234:16700 --listen-address=:29000 --console-address=:29002 --mountpoint=/home/dingofs/cli/cli1
55
# Created Date: 2024-10-30
66
# Author: Wei Dong (jackblack369)
77

88

99
g_curvefs="curve"
10-
g_curvefs_operator="fs gateway"
10+
g_curvefs_operator="gateway"
1111
g_mdsaddr="--mdsaddr="
1212
g_listen_address="--listen-address="
1313
g_console_address="--console-address="

0 commit comments

Comments
 (0)