diff --git a/cmd/root.go b/cmd/root.go
index 00fba60e..c4412111 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -46,7 +46,8 @@ func Execute() {
}
func initFuncs(cmd *cobra.Command, args []string) {
- logfile := viper.GetString("logfile")
+ viper.BindEnv("log.file", "LOGRUS_FILE")
+ logfile := viper.GetString("log.file")
if logfile != "" {
file, err := os.OpenFile(logfile,
os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
@@ -68,11 +69,11 @@ func initFuncs(cmd *cobra.Command, args []string) {
prom.Init()
}
- if viper.GetBool("http") {
+ if viper.GetBool("prom.http") {
addr := fmt.Sprintf(
"%s:%s",
- viper.GetString("http.addr"),
- viper.GetString("http.port"),
+ viper.GetString("prom.http.addr"),
+ viper.GetString("prom.http.port"),
)
prom.Serve(addr)
}
@@ -98,34 +99,34 @@ func init() {
viper.AutomaticEnv()
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file location")
- rootCmd.PersistentFlags().String("logfile", "", "file path for logging")
rootCmd.PersistentFlags().String("database-name", "vulcanize_public", "database name")
rootCmd.PersistentFlags().Int("database-port", 5432, "database port")
rootCmd.PersistentFlags().String("database-hostname", "localhost", "database hostname")
rootCmd.PersistentFlags().String("database-user", "", "database user")
rootCmd.PersistentFlags().String("database-password", "", "database password")
rootCmd.PersistentFlags().String("client-ipcPath", "", "location of geth.ipc file")
- rootCmd.PersistentFlags().String("log-level", log.InfoLevel.String(), "Log level (trace, debug, info, warn, error, fatal, panic")
+ rootCmd.PersistentFlags().String("log-level", log.InfoLevel.String(), "log level (trace, debug, info, warn, error, fatal, panic)")
+ rootCmd.PersistentFlags().String("log-file", "", "file path for logging")
rootCmd.PersistentFlags().Bool("metrics", false, "enable metrics")
- rootCmd.PersistentFlags().Bool("http", false, "enable http service for prometheus")
- rootCmd.PersistentFlags().String("http-addr", "127.0.0.1", "http host for prometheus")
- rootCmd.PersistentFlags().String("http-port", "8090", "http port for prometheus")
+ rootCmd.PersistentFlags().Bool("prom-http", false, "enable http service for prometheus")
+ rootCmd.PersistentFlags().String("prom-http-addr", "127.0.0.1", "http host for prometheus")
+ rootCmd.PersistentFlags().String("prom-http-port", "8090", "http port for prometheus")
- viper.BindPFlag("logfile", rootCmd.PersistentFlags().Lookup("logfile"))
viper.BindPFlag("database.name", rootCmd.PersistentFlags().Lookup("database-name"))
viper.BindPFlag("database.port", rootCmd.PersistentFlags().Lookup("database-port"))
viper.BindPFlag("database.hostname", rootCmd.PersistentFlags().Lookup("database-hostname"))
viper.BindPFlag("database.user", rootCmd.PersistentFlags().Lookup("database-user"))
viper.BindPFlag("database.password", rootCmd.PersistentFlags().Lookup("database-password"))
viper.BindPFlag("log.level", rootCmd.PersistentFlags().Lookup("log-level"))
+ viper.BindPFlag("log.file", rootCmd.PersistentFlags().Lookup("log-file"))
viper.BindPFlag("metrics", rootCmd.PersistentFlags().Lookup("metrics"))
- viper.BindPFlag("http", rootCmd.PersistentFlags().Lookup("http"))
- viper.BindPFlag("http.addr", rootCmd.PersistentFlags().Lookup("http-addr"))
- viper.BindPFlag("http.port", rootCmd.PersistentFlags().Lookup("http-port"))
+ viper.BindPFlag("prom.http", rootCmd.PersistentFlags().Lookup("prom-http"))
+ viper.BindPFlag("prom.http.addr", rootCmd.PersistentFlags().Lookup("prom-http-addr"))
+ viper.BindPFlag("prom.http.port", rootCmd.PersistentFlags().Lookup("prom-http-port"))
}
func initConfig() {
diff --git a/pkg/eth/api.go b/pkg/eth/api.go
index be8f689b..f61888e5 100644
--- a/pkg/eth/api.go
+++ b/pkg/eth/api.go
@@ -55,10 +55,14 @@ type PublicEthAPI struct {
// NewPublicEthAPI creates a new PublicEthAPI with the provided underlying Backend
func NewPublicEthAPI(b *Backend, client *rpc.Client) *PublicEthAPI {
+ var ethClient *ethclient.Client
+ if client != nil {
+ ethClient = ethclient.NewClient(client)
+ }
return &PublicEthAPI{
B: b,
rpc: client,
- ethClient: ethclient.NewClient(client),
+ ethClient: ethClient,
}
}
diff --git a/pkg/eth/api_test.go b/pkg/eth/api_test.go
index e7fe496b..8211ebf2 100644
--- a/pkg/eth/api_test.go
+++ b/pkg/eth/api_test.go
@@ -94,7 +94,7 @@ var _ = Describe("API", func() {
indexAndPublisher = eth2.NewIPLDPublisher(db)
backend, err = eth.NewEthBackend(db, ð.Config{})
Expect(err).ToNot(HaveOccurred())
- api = eth.NewPublicEthAPI(backend)
+ api = eth.NewPublicEthAPI(backend, nil)
err = indexAndPublisher.Publish(test_helpers.MockConvertedPayload)
Expect(err).ToNot(HaveOccurred())
uncles := test_helpers.MockBlock.Uncles()
diff --git a/pkg/eth/eth_call_test.go b/pkg/eth/eth_call_test.go
index cc5e6a67..0ad599df 100644
--- a/pkg/eth/eth_call_test.go
+++ b/pkg/eth/eth_call_test.go
@@ -86,7 +86,7 @@ var _ = Describe("eth_call", func() {
RPCGasCap: big.NewInt(10000000000),
})
Expect(err).ToNot(HaveOccurred())
- api = eth.NewPublicEthAPI(backend)
+ api = eth.NewPublicEthAPI(backend, nil)
// make the test blockchain (and state)
blocks, receipts, chain = test_helpers.MakeChain(4, test_helpers.Genesis, test_helpers.TestChainGen)
diff --git a/pkg/prom/db_stats_collector.go b/pkg/prom/db_stats_collector.go
index 0b225899..b0a4f502 100644
--- a/pkg/prom/db_stats_collector.go
+++ b/pkg/prom/db_stats_collector.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2020 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package prom
import (
diff --git a/pkg/prom/middleware.go b/pkg/prom/middleware.go
index b2daa79f..9397576f 100644
--- a/pkg/prom/middleware.go
+++ b/pkg/prom/middleware.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2020 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package prom
import (
diff --git a/pkg/prom/prom.go b/pkg/prom/prom.go
index 72a282ce..f2bd5792 100644
--- a/pkg/prom/prom.go
+++ b/pkg/prom/prom.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2020 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package prom
import (
diff --git a/pkg/prom/serve.go b/pkg/prom/serve.go
index 058d1772..12257d51 100644
--- a/pkg/prom/serve.go
+++ b/pkg/prom/serve.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2020 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package prom
import (