1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
run.go 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
package cmd
import (
"flag"
"os"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/cmd/instance"
)
func genRunCmd(name, version string, beatCreator beat.Creator, runFlags *pflag.FlagSet) *cobra.Command {
runCmd := cobra.Command{
Use: "run",
Short: "Run " + name,
Run: func(cmd *cobra.Command, args []string) {
err := instance.Run(name, version, beatCreator)
if err != nil {
os.Exit(1)
}
},
}
// Run subcommand flags, only available to *beat run
runCmd.Flags().AddGoFlag(flag.CommandLine.Lookup("N"))
runCmd.Flags().AddGoFlag(flag.CommandLine.Lookup("httpprof"))
runCmd.Flags().AddGoFlag(flag.CommandLine.Lookup("cpuprofile"))
runCmd.Flags().AddGoFlag(flag.CommandLine.Lookup("memprofile"))
// TODO deprecate in favor of subcommands (7.0):
runCmd.Flags().AddGoFlag(flag.CommandLine.Lookup("configtest"))
runCmd.Flags().AddGoFlag(flag.CommandLine.Lookup("version"))
runCmd.Flags().MarkDeprecated("version", "version flag has been deprectad, use version subcommand")
runCmd.Flags().MarkDeprecated("configtest", "configtest flag has been deprectad, use test config subcommand")
if runFlags != nil {
runCmd.Flags().AddFlagSet(runFlags)
}
return &runCmd
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v6.0.0-beta2

搜索帮助