github.com/reapchain/go-reapchain@v0.2.15-0.20210609012950-9735c110c705/cmd/puppeth/wizard_ethstats.go (about) 1 // Copyright 2017 The go-ethereum Authors 2 // This file is part of go-ethereum. 3 // 4 // go-ethereum is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // go-ethereum is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. 16 17 package main 18 19 import ( 20 "fmt" 21 22 "github.com/ethereum/go-ethereum/log" 23 ) 24 25 // deployEthstats queries the user for various input on deploying an ethstats 26 // monitoring server, after which it executes it. 27 func (w *wizard) deployEthstats() { 28 // Select the server to interact with 29 server := w.selectServer() 30 if server == "" { 31 return 32 } 33 client := w.servers[server] 34 35 // Retrieve any active ethstats configurations from the server 36 infos, err := checkEthstats(client, w.network) 37 if err != nil { 38 infos = ðstatsInfos{ 39 port: 80, 40 host: client.server, 41 secret: "", 42 } 43 } 44 // Figure out which port to listen on 45 fmt.Println() 46 fmt.Printf("Which port should ethstats listen on? (default = %d)\n", infos.port) 47 infos.port = w.readDefaultInt(infos.port) 48 49 // Figure which virtual-host to deploy ethstats on 50 if infos.host, err = w.ensureVirtualHost(client, infos.port, infos.host); err != nil { 51 log.Error("Failed to decide on ethstats host", "err", err) 52 return 53 } 54 // Port and proxy settings retrieved, figure out the secret and boot ethstats 55 fmt.Println() 56 if infos.secret == "" { 57 fmt.Printf("What should be the secret password for the API? (must not be empty)\n") 58 infos.secret = w.readString() 59 } else { 60 fmt.Printf("What should be the secret password for the API? (default = %s)\n", infos.secret) 61 infos.secret = w.readDefaultString(infos.secret) 62 } 63 // Try to deploy the ethstats server on the host 64 trusted := make([]string, 0, len(w.servers)) 65 for _, client := range w.servers { 66 if client != nil { 67 trusted = append(trusted, client.address) 68 } 69 } 70 if out, err := deployEthstats(client, w.network, infos.port, infos.secret, infos.host, trusted); err != nil { 71 log.Error("Failed to deploy ethstats container", "err", err) 72 if len(out) > 0 { 73 fmt.Printf("%s\n", out) 74 } 75 return 76 } 77 // All ok, run a network scan to pick any changes up 78 w.networkStats(false) 79 }