From 174f049507b8ef84d5e8a131d555468686d2091d Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Thu, 7 Dec 2023 11:43:48 +0800 Subject: [PATCH] fix: remove listen flag default value --- cmd/main.go | 1 - cmd/rpc.go | 6 +++--- cmd/run.go | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index b1c7b7f..9487454 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -62,7 +62,6 @@ func main() { &cli.StringFlag{ Name: "listen", Usage: "listen address for the service", - Value: "0.0.0.0:1234", }, &cli.StringFlag{ Name: "repo", diff --git a/cmd/rpc.go b/cmd/rpc.go index be2b7f3..1fff847 100644 --- a/cmd/rpc.go +++ b/cmd/rpc.go @@ -26,7 +26,7 @@ import ( "go.opencensus.io/plugin/ochttp" ) -func serveRPC(ctx context.Context, cfg *config.Config, listen string, jwt jwtclient.IJwtAuthClient, full api.FullNode, localApi local_api.LocalAPI, stop dix.StopFunc, maxRequestSize int64) error { +func serveRPC(ctx context.Context, cfg *config.Config, jwt jwtclient.IJwtAuthClient, full api.FullNode, localApi local_api.LocalAPI, stop dix.StopFunc, maxRequestSize int64) error { serverOptions := []jsonrpc.ServerOption{} if maxRequestSize > 0 { serverOptions = append(serverOptions, jsonrpc.WithMaxRequestSize(maxRequestSize)) @@ -96,7 +96,7 @@ func serveRPC(ctx context.Context, cfg *config.Config, listen string, jwt jwtcli } server := http.Server{ - Addr: listen, + Addr: cfg.API.ListenAddress, Handler: allHandler, BaseContext: func(net.Listener) context.Context { return ctx @@ -126,7 +126,7 @@ func serveRPC(ctx context.Context, cfg *config.Config, listen string, jwt jwtcli signal.Notify(sigCh, syscall.SIGTERM, syscall.SIGINT) - log.Infow("start http server", "addr", listen) + log.Infow("start http server", "addr", cfg.API.ListenAddress) if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed { return err } diff --git a/cmd/run.go b/cmd/run.go index 0cd5e2d..a0782a8 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -129,7 +129,6 @@ var runCmd = &cli.Command{ return serveRPC( appCtx, cfg, - cctx.String("listen"), localJwt, full, localApi,