[add] start --disable-watching
This commit is contained in:
parent
81ba5668f2
commit
b538fd8747
1 changed files with 9 additions and 3 deletions
12
cmd/start.go
12
cmd/start.go
|
|
@ -1,12 +1,14 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
@ -21,7 +23,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var startDebug = false
|
var startDebug = false
|
||||||
var startAlpha = false
|
var startDisableWatching = false
|
||||||
|
|
||||||
var startCmd = &cobra.Command{
|
var startCmd = &cobra.Command{
|
||||||
Use: "start",
|
Use: "start",
|
||||||
|
|
@ -74,7 +76,9 @@ var startCmd = &cobra.Command{
|
||||||
printApis(false)
|
printApis(false)
|
||||||
printTasks(false)
|
printTasks(false)
|
||||||
printSchedules(false)
|
printSchedules(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if mode == "development" && !startDisableWatching {
|
||||||
// Watching
|
// Watching
|
||||||
fmt.Println(color.WhiteString("\n---------------------------------"))
|
fmt.Println(color.WhiteString("\n---------------------------------"))
|
||||||
fmt.Println(color.WhiteString(L("Watching")))
|
fmt.Println(color.WhiteString(L("Watching")))
|
||||||
|
|
@ -95,7 +99,9 @@ var startCmd = &cobra.Command{
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-interrupt:
|
case <-interrupt:
|
||||||
service.Stop(func() {
|
ctx, canceled := context.WithTimeout(context.Background(), (5 * time.Second))
|
||||||
|
defer canceled()
|
||||||
|
service.StopWithContext(ctx, func() {
|
||||||
fmt.Println(color.GreenString(L("✨STOPPED✨")))
|
fmt.Println(color.GreenString(L("✨STOPPED✨")))
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
|
|
@ -206,5 +212,5 @@ func colorMehtod(method string) string {
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
startCmd.PersistentFlags().BoolVarP(&startDebug, "debug", "", false, L("Development mode"))
|
startCmd.PersistentFlags().BoolVarP(&startDebug, "debug", "", false, L("Development mode"))
|
||||||
startCmd.PersistentFlags().BoolVarP(&startAlpha, "alpha", "", false, L("Enabled unstable features"))
|
startCmd.PersistentFlags().BoolVarP(&startDisableWatching, "disable-watching", "", false, L("Disable watching"))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue