aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/puppeth/module_ethstats.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-11-24 16:56:33 +0800
committerGitHub <noreply@github.com>2017-11-24 16:56:33 +0800
commitf9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e (patch)
treefa8b344aedb3d56c2cd904173053a5273ec87a67 /cmd/puppeth/module_ethstats.go
parent35801f938e21430f8fb0f2e1c3de5db7dbd21666 (diff)
parenta3a2c6b0d9f963c9377612cae1ed6ded6f216c2d (diff)
downloaddexon-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.tar
dexon-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.tar.gz
dexon-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.tar.bz2
dexon-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.tar.lz
dexon-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.tar.xz
dexon-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.tar.zst
dexon-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.zip
Merge pull request #15390 from karalabe/puppeth-devcon3
cmd/puppeth: new version as presented at devcon3
Diffstat (limited to 'cmd/puppeth/module_ethstats.go')
-rw-r--r--cmd/puppeth/module_ethstats.go34
1 files changed, 16 insertions, 18 deletions
diff --git a/cmd/puppeth/module_ethstats.go b/cmd/puppeth/module_ethstats.go
index 6ce662f65..20b7afe23 100644
--- a/cmd/puppeth/module_ethstats.go
+++ b/cmd/puppeth/module_ethstats.go
@@ -21,6 +21,7 @@ import (
"fmt"
"math/rand"
"path/filepath"
+ "strconv"
"strings"
"text/template"
@@ -30,21 +31,9 @@ import (
// ethstatsDockerfile is the Dockerfile required to build an ethstats backend
// and associated monitoring site.
var ethstatsDockerfile = `
-FROM mhart/alpine-node:latest
-
-RUN \
- apk add --update git && \
- git clone --depth=1 https://github.com/karalabe/eth-netstats && \
- apk del git && rm -rf /var/cache/apk/* && \
- \
- cd /eth-netstats && npm install && npm install -g grunt-cli && grunt
-
-WORKDIR /eth-netstats
-EXPOSE 3000
+FROM puppeth/ethstats:latest
RUN echo 'module.exports = {trusted: [{{.Trusted}}], banned: [{{.Banned}}], reserved: ["yournode"]};' > lib/utils/config.js
-
-CMD ["npm", "start"]
`
// ethstatsComposefile is the docker-compose.yml file required to deploy and
@@ -72,7 +61,7 @@ services:
// deployEthstats deploys a new ethstats container to a remote machine via SSH,
// docker and docker-compose. If an instance with the specified network name
// already exists there, it will be overwritten!
-func deployEthstats(client *sshClient, network string, port int, secret string, vhost string, trusted []string, banned []string) ([]byte, error) {
+func deployEthstats(client *sshClient, network string, port int, secret string, vhost string, trusted []string, banned []string, nocache bool) ([]byte, error) {
// Generate the content to upload to the server
workdir := fmt.Sprintf("%d", rand.Int63())
files := make(map[string][]byte)
@@ -110,7 +99,10 @@ func deployEthstats(client *sshClient, network string, port int, secret string,
defer client.Run("rm -rf " + workdir)
// Build and deploy the ethstats service
- return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build", workdir, network))
+ if nocache {
+ return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate", workdir, network, network))
+ }
+ return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate", workdir, network))
}
// ethstatsInfos is returned from an ethstats status check to allow reporting
@@ -123,9 +115,15 @@ type ethstatsInfos struct {
banned []string
}
-// String implements the stringer interface.
-func (info *ethstatsInfos) String() string {
- return fmt.Sprintf("host=%s, port=%d, secret=%s, banned=%v", info.host, info.port, info.secret, info.banned)
+// Report converts the typed struct into a plain string->string map, containing
+// most - but not all - fields for reporting to the user.
+func (info *ethstatsInfos) Report() map[string]string {
+ return map[string]string{
+ "Website address": info.host,
+ "Website listener port": strconv.Itoa(info.port),
+ "Login secret": info.secret,
+ "Banned addresses": fmt.Sprintf("%v", info.banned),
+ }
}
// checkEthstats does a health-check against an ethstats server to verify whether