11package cmd
22
33import (
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
2325var startDebug = false
24- var startAlpha = false
26+ var startDisableWatching = false
2527
2628var 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
207213func 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