dev
This commit is contained in:
@@ -39,6 +39,7 @@ var (
|
||||
apiAddr string
|
||||
metricsAddr string
|
||||
reload time.Duration
|
||||
showConfig bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -102,6 +103,7 @@ func init() {
|
||||
flag.StringVar(&apiAddr, "api", "", "api service address")
|
||||
flag.StringVar(&metricsAddr, "metrics", "", "metrics service address")
|
||||
flag.DurationVar(&reload, "R", 0, "auto reload period (e.g. 30s, 1m)")
|
||||
flag.BoolVar(&showConfig, "P", false, "print config only")
|
||||
flag.Parse()
|
||||
|
||||
if printVersion {
|
||||
|
||||
@@ -2,7 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -23,6 +25,7 @@ import (
|
||||
metrics "github.com/go-gost/x/metrics/service"
|
||||
"github.com/go-gost/x/registry"
|
||||
"github.com/judwhite/go-svc"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type program struct {
|
||||
@@ -90,6 +93,17 @@ func (p *program) run(cfg *config.Config) error {
|
||||
svc.Serve()
|
||||
}()
|
||||
}
|
||||
if showConfig {
|
||||
if outputFormat == "json" {
|
||||
marshal, _ := json.Marshal(cfg)
|
||||
fmt.Println(string(marshal))
|
||||
} else {
|
||||
marshal, _ := yaml.Marshal(cfg)
|
||||
fmt.Println(string(marshal))
|
||||
}
|
||||
os.Exit(0)
|
||||
return nil
|
||||
}
|
||||
|
||||
if p.srvApi != nil {
|
||||
p.srvApi.Close()
|
||||
|
||||
Reference in New Issue
Block a user