good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
7b258c96
Unverified
Commit
7b258c96
authored
Oct 19, 2017
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
cmd/puppeth: concurrent server dials and health checks
parent
8c78449a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/puppeth/wizard.go
+3
-1
3 additions, 1 deletion
cmd/puppeth/wizard.go
cmd/puppeth/wizard_intro.go
+18
-6
18 additions, 6 deletions
cmd/puppeth/wizard_intro.go
cmd/puppeth/wizard_netstats.go
+121
-86
121 additions, 86 deletions
cmd/puppeth/wizard_netstats.go
with
142 additions
and
93 deletions
cmd/puppeth/wizard.go
+
3
−
1
View file @
7b258c96
...
...
@@ -28,6 +28,7 @@ import (
"sort"
"strconv"
"strings"
"sync"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
...
...
@@ -76,6 +77,7 @@ type wizard struct {
services
map
[
string
][]
string
// Ethereum services known to be running on servers
in
*
bufio
.
Reader
// Wrapper around stdin to allow reading user input
lock
sync
.
Mutex
// Lock to protect configs during concurrent service discovery
}
// read reads a single line from stdin, trimming if from spaces.
...
...
This diff is collapsed.
Click to expand it.
cmd/puppeth/wizard_intro.go
+
18
−
6
View file @
7b258c96
...
...
@@ -24,6 +24,7 @@ import (
"os"
"path/filepath"
"strings"
"sync"
"github.com/ethereum/go-ethereum/log"
)
...
...
@@ -80,14 +81,25 @@ func (w *wizard) run() {
}
else
if
err
:=
json
.
Unmarshal
(
blob
,
&
w
.
conf
);
err
!=
nil
{
log
.
Crit
(
"Previous configuration corrupted"
,
"path"
,
w
.
conf
.
path
,
"err"
,
err
)
}
else
{
// Dial all previously known servers concurrently
var
pend
sync
.
WaitGroup
for
server
,
pubkey
:=
range
w
.
conf
.
Servers
{
pend
.
Add
(
1
)
go
func
(
server
string
,
pubkey
[]
byte
)
{
defer
pend
.
Done
()
log
.
Info
(
"Dialing previously configured server"
,
"server"
,
server
)
client
,
err
:=
dial
(
server
,
pubkey
)
if
err
!=
nil
{
log
.
Error
(
"Previous server unreachable"
,
"server"
,
server
,
"err"
,
err
)
}
w
.
lock
.
Lock
()
w
.
servers
[
server
]
=
client
w
.
lock
.
Unlock
()
}(
server
,
pubkey
)
}
pend
.
Wait
()
w
.
networkStats
()
}
// Basics done, loop ad infinitum about what to do
...
...
This diff is collapsed.
Click to expand it.
cmd/puppeth/wizard_netstats.go
+
121
−
86
View file @
7b258c96
...
...
@@ -21,6 +21,7 @@ import (
"os"
"sort"
"strings"
"sync"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/log"
...
...
@@ -34,13 +35,51 @@ func (w *wizard) networkStats() {
log
.
Error
(
"No remote machines to gather stats from"
)
return
}
protips
:=
new
(
protips
)
// Clear out some previous configs to refill from current scan
w
.
conf
.
ethstats
=
""
w
.
conf
.
bootFull
=
w
.
conf
.
bootFull
[
:
0
]
w
.
conf
.
bootLight
=
w
.
conf
.
bootLight
[
:
0
]
// Iterate over all the specified hosts and check their status
stats
:=
make
(
serverStats
)
var
pend
sync
.
WaitGroup
stats
:=
make
(
serverStats
)
for
server
,
pubkey
:=
range
w
.
conf
.
Servers
{
client
:=
w
.
servers
[
server
]
pend
.
Add
(
1
)
// Gather the service stats for each server concurrently
go
func
(
server
string
,
pubkey
[]
byte
)
{
defer
pend
.
Done
()
stat
:=
w
.
gatherStats
(
server
,
pubkey
,
w
.
servers
[
server
])
// All status checks complete, report and check next server
w
.
lock
.
Lock
()
defer
w
.
lock
.
Unlock
()
delete
(
w
.
services
,
server
)
for
service
:=
range
stat
.
services
{
w
.
services
[
server
]
=
append
(
w
.
services
[
server
],
service
)
}
stats
[
server
]
=
stat
}(
server
,
pubkey
)
}
pend
.
Wait
()
// Print any collected stats and return
stats
.
render
()
}
// gatherStats gathers service statistics for a particular remote server.
func
(
w
*
wizard
)
gatherStats
(
server
string
,
pubkey
[]
byte
,
client
*
sshClient
)
*
serverStat
{
// Gather some global stats to feed into the wizard
var
(
genesis
string
ethstats
string
bootFull
[]
string
bootLight
[]
string
)
// Ensure a valid SSH connection to the remote server
logger
:=
log
.
New
(
"server"
,
server
)
logger
.
Info
(
"Starting remote server health-check"
)
...
...
@@ -48,14 +87,12 @@ func (w *wizard) networkStats() {
address
:
client
.
address
,
services
:
make
(
map
[
string
]
map
[
string
]
string
),
}
stats
[
client
.
server
]
=
stat
if
client
==
nil
{
conn
,
err
:=
dial
(
server
,
pubkey
)
if
err
!=
nil
{
logger
.
Error
(
"Failed to establish remote connection"
,
"err"
,
err
)
stat
.
failure
=
err
.
Error
()
continue
return
stat
}
client
=
conn
}
...
...
@@ -75,7 +112,7 @@ func (w *wizard) networkStats() {
}
}
else
{
stat
.
services
[
"ethstats"
]
=
infos
.
Report
()
protips
.
ethstats
=
infos
.
config
ethstats
=
infos
.
config
}
logger
.
Debug
(
"Checking for bootnode availability"
)
if
infos
,
err
:=
checkNode
(
client
,
w
.
network
,
true
);
err
!=
nil
{
...
...
@@ -85,10 +122,10 @@ func (w *wizard) networkStats() {
}
else
{
stat
.
services
[
"bootnode"
]
=
infos
.
Report
()
protips
.
genesis
=
string
(
infos
.
genesis
)
protips
.
bootFull
=
append
(
protips
.
bootFull
,
infos
.
enodeFull
)
genesis
=
string
(
infos
.
genesis
)
bootFull
=
append
(
bootFull
,
infos
.
enodeFull
)
if
infos
.
enodeLight
!=
""
{
protips
.
bootLight
=
append
(
protips
.
bootLight
,
infos
.
enodeLight
)
bootLight
=
append
(
bootLight
,
infos
.
enodeLight
)
}
}
logger
.
Debug
(
"Checking for sealnode availability"
)
...
...
@@ -98,7 +135,7 @@ func (w *wizard) networkStats() {
}
}
else
{
stat
.
services
[
"sealnode"
]
=
infos
.
Report
()
protips
.
genesis
=
string
(
infos
.
genesis
)
genesis
=
string
(
infos
.
genesis
)
}
logger
.
Debug
(
"Checking for faucet availability"
)
if
infos
,
err
:=
checkFaucet
(
client
,
w
.
network
);
err
!=
nil
{
...
...
@@ -116,30 +153,25 @@ func (w *wizard) networkStats() {
}
else
{
stat
.
services
[
"dashboard"
]
=
infos
.
Report
()
}
// All status checks complete, report and check next server
delete
(
w
.
services
,
server
)
for
service
:=
range
stat
.
services
{
w
.
services
[
server
]
=
append
(
w
.
services
[
server
],
service
)
}
}
// If a genesis block was found, load it into our configs
if
protips
.
genesis
!=
""
&&
w
.
conf
.
genesis
==
nil
{
genesis
:=
new
(
core
.
Genesis
)
if
err
:=
json
.
Unmarshal
([]
byte
(
protips
.
genesis
),
genesis
);
err
!=
nil
{
// Feed and newly discovered information into the wizard
w
.
lock
.
Lock
()
defer
w
.
lock
.
Unlock
()
if
genesis
!=
""
&&
w
.
conf
.
genesis
==
nil
{
g
:=
new
(
core
.
Genesis
)
if
err
:=
json
.
Unmarshal
([]
byte
(
genesis
),
g
);
err
!=
nil
{
log
.
Error
(
"Failed to parse remote genesis"
,
"err"
,
err
)
}
else
{
w
.
conf
.
genesis
=
genesis
protips
.
network
=
genesis
.
Config
.
ChainId
.
Int64
()
w
.
conf
.
genesis
=
g
}
}
if
protips
.
ethstats
!=
""
{
w
.
conf
.
ethstats
=
protips
.
ethstats
if
ethstats
!=
""
{
w
.
conf
.
ethstats
=
ethstats
}
w
.
conf
.
bootFull
=
protips
.
bootFull
w
.
conf
.
bootLight
=
protips
.
bootLight
w
.
conf
.
bootFull
=
append
(
w
.
conf
.
bootFull
,
bootFull
...
)
w
.
conf
.
bootLight
=
append
(
w
.
conf
.
bootLight
,
bootLight
...
)
// Print any collected stats and return
stats
.
render
()
return
stat
}
// serverStat is a collection of service configuration parameters and health
...
...
@@ -205,6 +237,9 @@ func (stats serverStats) render() {
}
sort
.
Strings
(
services
)
if
len
(
services
)
==
0
{
table
.
Append
([]
string
{
server
,
stats
[
server
]
.
address
,
""
,
""
,
""
})
}
for
j
,
service
:=
range
services
{
// Add an empty line between all services
if
j
>
0
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment