Skip to content

Commit

Permalink
Status page improvements (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
jholdstock authored and dajohi committed Aug 16, 2019
1 parent 5b83645 commit a517353
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 30 deletions.
30 changes: 15 additions & 15 deletions harness.sh
Expand Up @@ -38,14 +38,14 @@ fi
tmux new-session -d -s $SESSION

#################################################
# Setup the master node.
# Setup the dcrd node.
#################################################

tmux rename-window -t $SESSION 'master'
tmux rename-window -t $SESSION 'dcrd'

echo "Writing config for testnet dcrd node"
mkdir -p "${NODES_ROOT}/master"
cat > "${NODES_ROOT}/master/dcrd.conf" <<EOF
mkdir -p "${NODES_ROOT}/dcrd"
cat > "${NODES_ROOT}/dcrd/dcrd.conf" <<EOF
rpcuser=${RPC_USER}
rpcpass=${RPC_PASS}
rpccert=${DCRD_RPC_CERT}
Expand All @@ -55,8 +55,8 @@ testnet=true
logdir=${NODES_ROOT}/master/log
EOF

echo "Starting dcrd master node"
tmux send-keys "dcrd -C ${NODES_ROOT}/master/dcrd.conf" C-m
echo "Starting dcrd node"
tmux send-keys "dcrd -C ${NODES_ROOT}/dcrd/dcrd.conf" C-m

sleep 3 # Give dcrd time to start

Expand All @@ -75,30 +75,30 @@ for ((i = 1; i <= $NUMBER_OF_BACKENDS; i++)); do
# dcrwallet
#################################################
echo ""
echo "Writing config for voting-wallet-${i}"
mkdir -p "${NODES_ROOT}/voting-wallet-${i}"
cat > "${NODES_ROOT}/voting-wallet-${i}/dcrwallet.conf" <<EOF
echo "Writing config for dcrwallet-${i}"
mkdir -p "${NODES_ROOT}/dcrwallet-${i}"
cat > "${NODES_ROOT}/dcrwallet-${i}/dcrwallet.conf" <<EOF
username=${RPC_USER}
password=${RPC_PASS}
rpccert=${WALLET_RPC_CERT}
rpckey=${WALLET_RPC_KEY}
logdir=${NODES_ROOT}/voting-wallet-${i}/log
appdata=${NODES_ROOT}/voting-wallet-${i}
logdir=${NODES_ROOT}/dcrwallet-${i}/log
appdata=${NODES_ROOT}/dcrwallet-${i}
testnet=true
pass=${WALLET_PASS}
rpcconnect=${DCRD_RPC_LISTEN}
grpclisten=127.0.0.1:2010${i}
rpclisten=${WALLET_RPC_LISTEN}
EOF

echo "Starting voting-wallet-${i}"
tmux new-window -t $SESSION -n "voting-wallet-${i}"
tmux send-keys "dcrwallet -C ${NODES_ROOT}/voting-wallet-${i}/dcrwallet.conf --create" C-m
echo "Starting dcrwallet-${i}"
tmux new-window -t $SESSION -n "dcrwallet-${i}"
tmux send-keys "dcrwallet -C ${NODES_ROOT}/dcrwallet-${i}/dcrwallet.conf --create" C-m
sleep 2
tmux send-keys "${WALLET_PASS}" C-m "${WALLET_PASS}" C-m "n" C-m "y" C-m
sleep 2
tmux send-keys "${VOTING_WALLET_SEED}" C-m C-m
tmux send-keys "dcrwallet -C ${NODES_ROOT}/voting-wallet-${i}/dcrwallet.conf " C-m
tmux send-keys "dcrwallet -C ${NODES_ROOT}/dcrwallet-${i}/dcrwallet.conf " C-m
sleep 12 # Give dcrwallet time to start

#################################################
Expand Down
9 changes: 9 additions & 0 deletions public/css/styles.css
Expand Up @@ -8818,3 +8818,12 @@ https://flickity.metafizzy.co
background-repeat: no-repeat;
color: #a9b4bf;
}

.table-light > td.status-good{
background-color: #C4ECCA;
}


.table-light > td.status-bad{
background-color: #FEB8A5;
}
18 changes: 13 additions & 5 deletions stakepooldclient/stakepooldclient.go
Expand Up @@ -607,7 +607,12 @@ func (s *StakepooldManager) ImportScript(script []byte) (heightImported int64, e

// BackendStatus provides a summary of a single back-end server
type BackendStatus struct {
RPCStatus string
Host string
RPCStatus string
*WalletStatus
}

type WalletStatus struct {
DaemonConnected bool
VoteVersion uint32
Unlocked bool
Expand All @@ -621,6 +626,7 @@ func (s *StakepooldManager) BackendStatus() []BackendStatus {
stakepooldPageInfo := make([]BackendStatus, len(s.grpcConnections))

for i, conn := range s.grpcConnections {
stakepooldPageInfo[i].Host = conn.Target()
stakepooldPageInfo[i].RPCStatus = "Unknown"
state := conn.GetState()
switch state {
Expand All @@ -642,10 +648,12 @@ func (s *StakepooldManager) BackendStatus() []BackendStatus {
if err != nil {
log.Warnf("BackendStatus: WalletInfo RPC failed on stakepoold instance %s: %v", conn.Target(), err)
} else {
stakepooldPageInfo[i].DaemonConnected = resp.DaemonConnected
stakepooldPageInfo[i].VoteVersion = resp.VoteVersion
stakepooldPageInfo[i].Unlocked = resp.Unlocked
stakepooldPageInfo[i].Voting = resp.Voting
stakepooldPageInfo[i].WalletStatus = &WalletStatus{
DaemonConnected: resp.DaemonConnected,
VoteVersion: resp.VoteVersion,
Unlocked: resp.Unlocked,
Voting: resp.Voting,
}
}
}

Expand Down
43 changes: 33 additions & 10 deletions views/admin/status.html
Expand Up @@ -17,23 +17,46 @@ <h1 class="d-flex justify-content-between align-items-center">
<table class="table" cellspacing="0" width="100%">
<thead class="thead-light">
<tr>
<th scope="col" class="text-center">Back-end ID</th>
<th scope="col" class="text-center">RPC Status</th>
<th scope="col" class="text-center">Host</th>
<th scope="col" class="text-center">Stakepoold RPC Status</th>
<th scope="col" class="text-center">DaemonConnected</th>
<th scope="col" class="text-center">VoteVersion</th>
<th scope="col" class="text-center">Unlocked</th>
<th scope="col" class="text-center">Voting</th>
<th scope="col" class="text-center">VoteVersion</th>
</tr>
</thead>
<tbody>
{{ range $i, $backend := .BackendStatus }}
{{ range .BackendStatus }}
<tr class="table-light">
<td class="text-center">{{$i}}</td>
<td class="text-center">{{ $backend.RPCStatus }}</td>
<td class="text-center">{{ $backend.DaemonConnected }}</td>
<td class="text-center">{{ $backend.VoteVersion }}</td>
<td class="text-center">{{ $backend.Unlocked }}</td>
<td class="text-center">{{ $backend.Voting }}</td>
<td class="text-center">{{ .Host }}</td>

<td class="text-center
{{ if eq .RPCStatus "Ready" }}status-good{{else}}status-bad{{end}}"
>{{ .RPCStatus }}</td>

{{ with .WalletStatus }}

<td class="text-center
{{ if eq .DaemonConnected true }}status-good{{else}}status-bad{{end}}"
>{{ .DaemonConnected }}</td>


<td class="text-center
{{ if eq .Unlocked true }}status-good{{else}}status-bad{{end}}"
>{{ .Unlocked }}</td>


<td class="text-center
{{ if eq .Voting false }}status-good{{else}}status-bad{{end}}"
>{{ .Voting }}</td>

<td class="text-center">{{ .VoteVersion }}</td>

{{else}}

<td class="text-center status-bad" colspan="4">Cannot get wallet stats</td>

{{end}}
</tr>
{{end}}
</tbody>
Expand Down

0 comments on commit a517353

Please sign in to comment.