Fix listen flag (#1897)

This commit is contained in:
Adam Babik 2020-03-10 13:40:35 +01:00 committed by GitHub
parent 241e4ad1dd
commit 6fdeb9b115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 43 deletions

View File

@ -17,13 +17,11 @@ GIT_COMMIT = $(shell git rev-parse --short HEAD)
AUTHOR = $(shell echo $$USER)
ENABLE_METRICS ?= true
BUILD_FLAGS ?= $(shell echo "-ldflags '\
-X main.buildStamp=`date -u '+%Y-%m-%d.%H:%M:%S'` \
BUILD_FLAGS ?= $(shell echo "-ldflags='\
-X github.com/status-im/status-go/params.Version=$(RELEASE_TAG) \
-X github.com/status-im/status-go/params.GitCommit=$(GIT_COMMIT) \
-X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr=$(ENABLE_METRICS)'")
BUILD_FLAGS_MOBILE ?= $(shell echo "-ldflags '\
-X main.buildStamp=`date -u '+%Y-%m-%d.%H:%M:%S'` \
BUILD_FLAGS_MOBILE ?= $(shell echo "-ldflags='\
-X github.com/status-im/status-go/params.Version=$(RELEASE_TAG) \
-X github.com/status-im/status-go/params.GitCommit=$(GIT_COMMIT)'")
@ -70,7 +68,7 @@ nimbus-statusgo: nimbus ##@build Build status-go (based on Nimbus node) as statu
@echo "Run \"build/bin/statusd -h\" to view available commands."
statusgo: ##@build Build status-go as statusd server
go build -i -o $(GOBIN)/statusd -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./cmd/statusd
go build -mod=vendor -i -o $(GOBIN)/statusd -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./cmd/statusd
@echo "Compilation done."
@echo "Run \"build/bin/statusd -h\" to view available commands."

View File

@ -7,11 +7,9 @@ ARG build_tags
ARG build_flags
RUN mkdir -p /go/src/github.com/status-im/status-go
ADD . /go/src/github.com/status-im/status-go
RUN cd /go/src/github.com/status-im/status-go && \
make statusgo \
BUILD_TAGS="$build_tags" \
BUILD_FLAGS="$build_flags"
WORKDIR /go/src/github.com/status-im/status-go
ADD . .
RUN make statusgo BUILD_TAGS="$build_tags" BUILD_FLAGS="$build_flags"
# Copy the binary to the second image
FROM alpine:latest

View File

@ -32,10 +32,6 @@ const (
serverClientName = "Statusd"
)
var (
buildStamp = "N/A" // rely on linker: -ldflags -X main.buildStamp"
)
var (
configFiles configFlags
logLevel = flag.String("log", "", `Log level, one of: "ERROR", "WARN", "INFO", "DEBUG", and "TRACE"`)
@ -65,7 +61,7 @@ var (
[]string{params.FleetProd, params.FleetStaging, params.FleetTest}, params.FleetProd,
),
)
listenAddr = flag.String("addr", ":30303", "address to bind listener to")
listenAddr = flag.String("addr", "", "address to bind listener to")
// don't change the name of this flag, https://github.com/ethereum/go-ethereum/blob/master/metrics/metrics.go#L41
metricsEnabled = flag.Bool("metrics", false, "Expose ethereum metrics with debug_metrics jsonrpc call")
@ -113,7 +109,11 @@ func main() {
os.Exit(1)
}
config.ListenAddr = *listenAddr
// Use listenAddr if and only if explicitly provided in the arguments.
// The default value is set in params.NewNodeConfigWithDefaultsAndFiles().
if *listenAddr != "" {
config.ListenAddr = *listenAddr
}
if *register && *mailserver {
config.RegisterTopics = append(config.RegisterTopics, params.MailServerDiscv5Topic)
@ -134,7 +134,7 @@ func main() {
config.Name = serverClientName
if *version {
printVersion(config, buildStamp)
printVersion(config)
return
}
@ -286,14 +286,9 @@ func configureStatusService(flagValue string, nodeConfig *params.NodeConfig) (*p
}
// printVersion prints verbose output about version and config.
func printVersion(config *params.NodeConfig, buildStamp string) {
func printVersion(config *params.NodeConfig) {
fmt.Println(strings.Title(config.Name))
fmt.Println("Version:", config.Version)
if buildStamp != "" {
fmt.Println("Build Stamp:", buildStamp)
}
fmt.Println("Network ID:", config.NetworkID)
fmt.Println("Go Version:", runtime.Version())
fmt.Println("OS:", runtime.GOOS)

View File

@ -825,12 +825,8 @@ func (c *NodeConfig) Validate() error {
return fmt.Errorf("PFSEnabled is true, but InstallationID is empty")
}
if len(c.ClusterConfig.RendezvousNodes) == 0 {
if c.Rendezvous {
return fmt.Errorf("Rendezvous is enabled, but ClusterConfig.RendezvousNodes is empty")
}
} else if !c.Rendezvous {
return fmt.Errorf("Rendezvous is disabled, but ClusterConfig.RendezvousNodes is not empty")
if len(c.ClusterConfig.RendezvousNodes) == 0 && c.Rendezvous {
return fmt.Errorf("Rendezvous is enabled, but ClusterConfig.RendezvousNodes is empty")
}
return nil

View File

@ -214,20 +214,6 @@ func TestNodeConfigValidate(t *testing.T) {
}`,
Error: "Rendezvous is enabled, but ClusterConfig.RendezvousNodes is empty",
},
{
Name: "Validate that ClusterConfig.RendezvousNodes is verified to contain nodes if Rendezvous is enabled",
Config: `{
"NetworkId": 1,
"DataDir": "/some/dir",
"KeyStoreDir": "/some/dir",
"NoDiscovery": true,
"Rendezvous": false,
"ClusterConfig": {
"RendezvousNodes": ["a"]
}
}`,
Error: "Rendezvous is disabled, but ClusterConfig.RendezvousNodes is not empty",
},
{
Name: "Validate that WhisperConfig.DataDir is checked to not be empty if mailserver is enabled",
Config: `{