mirror of
https://github.com/hibiken/asynq.git
synced 2025-10-03 05:12:01 +08:00
(cli): Add --refresh flag to dash command
This commit is contained in:
@@ -5,18 +5,22 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/MakeNowJust/heredoc/v2"
|
"github.com/MakeNowJust/heredoc/v2"
|
||||||
"github.com/hibiken/asynq/tools/asynq/cmd/dash"
|
"github.com/hibiken/asynq/tools/asynq/cmd/dash"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
flagDebug = false
|
flagDebug = false
|
||||||
flagUseRealData = false
|
flagUseRealData = false
|
||||||
|
flagPollInterval = 8 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(dashCmd)
|
rootCmd.AddCommand(dashCmd)
|
||||||
|
dashCmd.Flags().DurationVar(&flagPollInterval, "refresh", 8*time.Second, "Interval between data refresh")
|
||||||
// TODO: Remove this debug once we're done
|
// TODO: Remove this debug once we're done
|
||||||
dashCmd.Flags().BoolVar(&flagDebug, "debug", false, "Print debug info")
|
dashCmd.Flags().BoolVar(&flagDebug, "debug", false, "Print debug info")
|
||||||
dashCmd.Flags().BoolVar(&flagUseRealData, "realdata", true, "Use real data in redis")
|
dashCmd.Flags().BoolVar(&flagUseRealData, "realdata", true, "Use real data in redis")
|
||||||
@@ -30,8 +34,9 @@ var dashCmd = &cobra.Command{
|
|||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
dash.Run(dash.Options{
|
dash.Run(dash.Options{
|
||||||
DebugMode: flagDebug,
|
DebugMode: flagDebug,
|
||||||
UseRealData: flagUseRealData,
|
UseRealData: flagUseRealData,
|
||||||
|
PollInterval: flagPollInterval,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -77,7 +77,6 @@ func Run(opts Options) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
s.SetStyle(baseStyle) // set default text style
|
s.SetStyle(baseStyle) // set default text style
|
||||||
opts.PollInterval = 2 * time.Second
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
state = State{} // confined in this goroutine only; DO NOT SHARE
|
state = State{} // confined in this goroutine only; DO NOT SHARE
|
||||||
|
Reference in New Issue
Block a user