Skip to content

Commit b538fd8

Browse files
committed
[add] start --disable-watching
1 parent 81ba566 commit b538fd8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cmd/start.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package cmd
22

33
import (
4+
"context"
45
"fmt"
56
"os"
67
"os/signal"
78
"path/filepath"
89
"strings"
910
"syscall"
11+
"time"
1012

1113
"github.com/fatih/color"
1214
"github.com/spf13/cobra"
@@ -21,7 +23,7 @@ import (
2123
)
2224

2325
var startDebug = false
24-
var startAlpha = false
26+
var startDisableWatching = false
2527

2628
var startCmd = &cobra.Command{
2729
Use: "start",
@@ -74,7 +76,9 @@ var startCmd = &cobra.Command{
7476
printApis(false)
7577
printTasks(false)
7678
printSchedules(false)
79+
}
7780

81+
if mode == "development" && !startDisableWatching {
7882
// Watching
7983
fmt.Println(color.WhiteString("\n---------------------------------"))
8084
fmt.Println(color.WhiteString(L("Watching")))
@@ -95,7 +99,9 @@ var startCmd = &cobra.Command{
9599
for {
96100
select {
97101
case <-interrupt:
98-
service.Stop(func() {
102+
ctx, canceled := context.WithTimeout(context.Background(), (5 * time.Second))
103+
defer canceled()
104+
service.StopWithContext(ctx, func() {
99105
fmt.Println(color.GreenString(L("✨STOPPED✨")))
100106
})
101107
return
@@ -206,5 +212,5 @@ func colorMehtod(method string) string {
206212

207213
func init() {
208214
startCmd.PersistentFlags().BoolVarP(&startDebug, "debug", "", false, L("Development mode"))
209-
startCmd.PersistentFlags().BoolVarP(&startAlpha, "alpha", "", false, L("Enabled unstable features"))
215+
startCmd.PersistentFlags().BoolVarP(&startDisableWatching, "disable-watching", "", false, L("Disable watching"))
210216
}

0 commit comments

Comments
 (0)