aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/puppeth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-10-19 21:00:55 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-11-21 21:09:33 +0800
commitda3b9f831e6bb8f8a3c589e5cd8426fd9da72eea (patch)
treefb9cca2507788d43e79113a42d9abc3e221e6378 /cmd/puppeth
parent7b258c96816df56e642df7e314e8052213af70fa (diff)
downloaddexon-da3b9f831e6bb8f8a3c589e5cd8426fd9da72eea.tar
dexon-da3b9f831e6bb8f8a3c589e5cd8426fd9da72eea.tar.gz
dexon-da3b9f831e6bb8f8a3c589e5cd8426fd9da72eea.tar.bz2
dexon-da3b9f831e6bb8f8a3c589e5cd8426fd9da72eea.tar.lz
dexon-da3b9f831e6bb8f8a3c589e5cd8426fd9da72eea.tar.xz
dexon-da3b9f831e6bb8f8a3c589e5cd8426fd9da72eea.tar.zst
dexon-da3b9f831e6bb8f8a3c589e5cd8426fd9da72eea.zip
cmd/puppeth: support deploying services with forced rebuilds
Diffstat (limited to 'cmd/puppeth')
-rw-r--r--cmd/puppeth/module_dashboard.go7
-rw-r--r--cmd/puppeth/module_ethstats.go7
-rw-r--r--cmd/puppeth/module_faucet.go7
-rw-r--r--cmd/puppeth/module_nginx.go9
-rw-r--r--cmd/puppeth/module_node.go7
-rw-r--r--cmd/puppeth/wizard_dashboard.go6
-rw-r--r--cmd/puppeth/wizard_ethstats.go6
-rw-r--r--cmd/puppeth/wizard_faucet.go6
-rw-r--r--cmd/puppeth/wizard_nginx.go6
-rw-r--r--cmd/puppeth/wizard_node.go8
10 files changed, 52 insertions, 17 deletions
diff --git a/cmd/puppeth/module_dashboard.go b/cmd/puppeth/module_dashboard.go
index 7d01f6f0a..b08dbbff1 100644
--- a/cmd/puppeth/module_dashboard.go
+++ b/cmd/puppeth/module_dashboard.go
@@ -437,7 +437,7 @@ services:
// deployDashboard deploys a new dashboard 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 deployDashboard(client *sshClient, network string, port int, vhost string, services map[string]string, conf *config, ethstats bool) ([]byte, error) {
+func deployDashboard(client *sshClient, network string, port int, vhost string, services map[string]string, conf *config, ethstats bool, nocache bool) ([]byte, error) {
// Generate the content to upload to the server
workdir := fmt.Sprintf("%d", rand.Int63())
files := make(map[string][]byte)
@@ -490,7 +490,10 @@ func deployDashboard(client *sshClient, network string, port int, vhost string,
defer client.Run("rm -rf " + workdir)
// Build and deploy the dashboard 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))
}
// dashboardInfos is returned from an dashboard status check to allow reporting
diff --git a/cmd/puppeth/module_ethstats.go b/cmd/puppeth/module_ethstats.go
index 2e83e366e..7ce3ca3cd 100644
--- a/cmd/puppeth/module_ethstats.go
+++ b/cmd/puppeth/module_ethstats.go
@@ -73,7 +73,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)
@@ -111,7 +111,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
diff --git a/cmd/puppeth/module_faucet.go b/cmd/puppeth/module_faucet.go
index 238aa115f..a53e6f61e 100644
--- a/cmd/puppeth/module_faucet.go
+++ b/cmd/puppeth/module_faucet.go
@@ -95,7 +95,7 @@ services:
// deployFaucet deploys a new faucet 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 deployFaucet(client *sshClient, network string, bootnodes []string, config *faucetInfos) ([]byte, error) {
+func deployFaucet(client *sshClient, network string, bootnodes []string, config *faucetInfos, nocache bool) ([]byte, error) {
// Generate the content to upload to the server
workdir := fmt.Sprintf("%d", rand.Int63())
files := make(map[string][]byte)
@@ -146,7 +146,10 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config
defer client.Run("rm -rf " + workdir)
// Build and deploy the faucet 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))
}
// faucetInfos is returned from an faucet status check to allow reporting various
diff --git a/cmd/puppeth/module_nginx.go b/cmd/puppeth/module_nginx.go
index 67084c80a..ade0e4963 100644
--- a/cmd/puppeth/module_nginx.go
+++ b/cmd/puppeth/module_nginx.go
@@ -55,7 +55,7 @@ services:
// deployNginx deploys a new nginx reverse-proxy container to expose one or more
// HTTP services running on a single host. If an instance with the specified
// network name already exists there, it will be overwritten!
-func deployNginx(client *sshClient, network string, port int) ([]byte, error) {
+func deployNginx(client *sshClient, network string, port int, nocache bool) ([]byte, error) {
log.Info("Deploying nginx reverse-proxy", "server", client.server, "port", port)
// Generate the content to upload to the server
@@ -79,8 +79,11 @@ func deployNginx(client *sshClient, network string, port int) ([]byte, error) {
}
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))
+ // Build and deploy the reverse-proxy service
+ 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))
}
// nginxInfos is returned from an nginx reverse-proxy status check to allow
diff --git a/cmd/puppeth/module_node.go b/cmd/puppeth/module_node.go
index ad50cd80a..17e8a1a99 100644
--- a/cmd/puppeth/module_node.go
+++ b/cmd/puppeth/module_node.go
@@ -81,7 +81,7 @@ services:
// deployNode deploys a new Ethereum node 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 deployNode(client *sshClient, network string, bootv4, bootv5 []string, config *nodeInfos) ([]byte, error) {
+func deployNode(client *sshClient, network string, bootv4, bootv5 []string, config *nodeInfos, nocache bool) ([]byte, error) {
kind := "sealnode"
if config.keyJSON == "" && config.etherbase == "" {
kind = "bootnode"
@@ -143,7 +143,10 @@ func deployNode(client *sshClient, network string, bootv4, bootv5 []string, conf
defer client.Run("rm -rf " + workdir)
// Build and deploy the boot or seal node 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))
}
// nodeInfos is returned from a boot or seal node status check to allow reporting
diff --git a/cmd/puppeth/wizard_dashboard.go b/cmd/puppeth/wizard_dashboard.go
index 3f68c93a4..b59489b03 100644
--- a/cmd/puppeth/wizard_dashboard.go
+++ b/cmd/puppeth/wizard_dashboard.go
@@ -120,7 +120,11 @@ func (w *wizard) deployDashboard() {
ethstats = w.readDefaultString("y") == "y"
}
// Try to deploy the dashboard container on the host
- if out, err := deployDashboard(client, w.network, infos.port, infos.host, listing, &w.conf, ethstats); err != nil {
+ fmt.Println()
+ fmt.Printf("Should the dashboard be built from scratch (y/n)? (default = no)\n")
+ nocache := w.readDefaultString("n") != "n"
+
+ if out, err := deployDashboard(client, w.network, infos.port, infos.host, listing, &w.conf, ethstats, nocache); err != nil {
log.Error("Failed to deploy dashboard container", "err", err)
if len(out) > 0 {
fmt.Printf("%s\n", out)
diff --git a/cmd/puppeth/wizard_ethstats.go b/cmd/puppeth/wizard_ethstats.go
index ff75a9d5d..1bde5a3fd 100644
--- a/cmd/puppeth/wizard_ethstats.go
+++ b/cmd/puppeth/wizard_ethstats.go
@@ -98,13 +98,17 @@ func (w *wizard) deployEthstats() {
sort.Strings(infos.banned)
}
// Try to deploy the ethstats server on the host
+ fmt.Println()
+ fmt.Printf("Should the ethstats be built from scratch (y/n)? (default = no)\n")
+ nocache := w.readDefaultString("n") != "n"
+
trusted := make([]string, 0, len(w.servers))
for _, client := range w.servers {
if client != nil {
trusted = append(trusted, client.address)
}
}
- if out, err := deployEthstats(client, w.network, infos.port, infos.secret, infos.host, trusted, infos.banned); err != nil {
+ if out, err := deployEthstats(client, w.network, infos.port, infos.secret, infos.host, trusted, infos.banned, nocache); err != nil {
log.Error("Failed to deploy ethstats container", "err", err)
if len(out) > 0 {
fmt.Printf("%s\n", out)
diff --git a/cmd/puppeth/wizard_faucet.go b/cmd/puppeth/wizard_faucet.go
index 08e471ef8..e9d5c6016 100644
--- a/cmd/puppeth/wizard_faucet.go
+++ b/cmd/puppeth/wizard_faucet.go
@@ -190,7 +190,11 @@ func (w *wizard) deployFaucet() {
}
}
// Try to deploy the faucet server on the host
- if out, err := deployFaucet(client, w.network, w.conf.bootLight, infos); err != nil {
+ fmt.Println()
+ fmt.Printf("Should the faucet be built from scratch (y/n)? (default = no)\n")
+ nocache := w.readDefaultString("n") != "n"
+
+ if out, err := deployFaucet(client, w.network, w.conf.bootLight, infos, nocache); err != nil {
log.Error("Failed to deploy faucet container", "err", err)
if len(out) > 0 {
fmt.Printf("%s\n", out)
diff --git a/cmd/puppeth/wizard_nginx.go b/cmd/puppeth/wizard_nginx.go
index 86fba29f5..919ab270b 100644
--- a/cmd/puppeth/wizard_nginx.go
+++ b/cmd/puppeth/wizard_nginx.go
@@ -41,7 +41,11 @@ func (w *wizard) ensureVirtualHost(client *sshClient, port int, def string) (str
fmt.Println()
fmt.Println("Allow sharing the port with other services (y/n)? (default = yes)")
if w.readDefaultString("y") == "y" {
- if out, err := deployNginx(client, w.network, port); err != nil {
+ fmt.Println()
+ fmt.Printf("Should the reverse-proxy be rebuilt from scratch (y/n)? (default = no)\n")
+ nocache := w.readDefaultString("n") != "n"
+
+ if out, err := deployNginx(client, w.network, port, nocache); err != nil {
log.Error("Failed to deploy reverse-proxy", "err", err)
if len(out) > 0 {
fmt.Printf("%s\n", out)
diff --git a/cmd/puppeth/wizard_node.go b/cmd/puppeth/wizard_node.go
index 69d1715a4..023da8e1e 100644
--- a/cmd/puppeth/wizard_node.go
+++ b/cmd/puppeth/wizard_node.go
@@ -44,7 +44,7 @@ func (w *wizard) deployNode(boot bool) {
}
client := w.servers[server]
- // Retrieve any active ethstats configurations from the server
+ // Retrieve any active node configurations from the server
infos, err := checkNode(client, w.network, boot)
if err != nil {
if boot {
@@ -145,7 +145,11 @@ func (w *wizard) deployNode(boot bool) {
infos.gasPrice = w.readDefaultFloat(infos.gasPrice)
}
// Try to deploy the full node on the host
- if out, err := deployNode(client, w.network, w.conf.bootFull, w.conf.bootLight, infos); err != nil {
+ fmt.Println()
+ fmt.Printf("Should the node be built from scratch (y/n)? (default = no)\n")
+ nocache := w.readDefaultString("n") != "n"
+
+ if out, err := deployNode(client, w.network, w.conf.bootFull, w.conf.bootLight, infos, nocache); err != nil {
log.Error("Failed to deploy Ethereum node container", "err", err)
if len(out) > 0 {
fmt.Printf("%s\n", out)