This commit is contained in:
wenyifan 2023-11-21 10:22:09 +08:00
parent 4c934cd737
commit b8b4e99aec
2 changed files with 11 additions and 0 deletions

View File

@ -23,6 +23,7 @@ var (
services stringList
nodes stringList
debug bool
showConfig bool
apiAddr string
metricsAddr string
)
@ -78,6 +79,7 @@ func init() {
flag.BoolVar(&printVersion, "V", false, "print version")
flag.StringVar(&outputFormat, "O", "", "output format, one of yaml|json format")
flag.BoolVar(&debug, "D", false, "debug mode")
flag.BoolVar(&showConfig, "P", false, "print config only")
flag.StringVar(&apiAddr, "api", "", "api service address")
flag.StringVar(&metricsAddr, "metrics", "", "metrics service address")
flag.Parse()

View File

@ -1,6 +1,8 @@
package main
import (
"fmt"
"gopkg.in/yaml.v2"
"net/http"
"os"
@ -93,6 +95,13 @@ func (p *program) Start() error {
log := logger.Default()
cfg := config.Global()
if showConfig {
marshal, _ := yaml.Marshal(cfg)
fmt.Println(string(marshal))
os.Exit(0)
return nil
}
if cfg.API != nil {
s, err := buildAPIService(cfg.API)
if err != nil {