diff --git a/pkg/common/cmd/root.go b/pkg/common/cmd/root.go index 37eee7cdf..e1269fe9f 100644 --- a/pkg/common/cmd/root.go +++ b/pkg/common/cmd/root.go @@ -22,12 +22,12 @@ func NewRootCmd() (rootCmd *RootCmd) { Short: "Start the server", Long: `Start the server`, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - if rootCmd.portFlag { - rootCmd.port = rootCmd.getPortFlag(cmd) - } - if rootCmd.prometheusPortFlag { - rootCmd.prometheusPort = rootCmd.getPrometheusPortFlag(cmd) - } + //if rootCmd.portFlag { + rootCmd.port = rootCmd.getPortFlag(cmd) + //} + //if rootCmd.prometheusPortFlag { + rootCmd.prometheusPort = rootCmd.getPrometheusPortFlag(cmd) + //} return rootCmd.getConfFromCmdAndInit(cmd) }, } @@ -42,6 +42,12 @@ func (r *RootCmd) AddRunE(f func(cmd RootCmd) error) { } } +func (r *RootCmd) AddRpc(f func(port, prometheusPort int) error) { + r.Command.RunE = func(cmd *cobra.Command, args []string) error { + return f(r.port, r.prometheusPort) + } +} + func (r *RootCmd) init() { r.Command.Flags().StringP(constant.FlagConf, "c", "", "Path to config file folder") }