Skip to content

Commit

Permalink
chore: 🤖 add support for log verification, missing staking warning
Browse files Browse the repository at this point in the history
  • Loading branch information
heldrida committed Oct 18, 2023
1 parent 6aa134f commit b21fec3
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions scripts/healthcheck
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ defaultLightningDiagnosticLogAbsPath="$defaultLightningLogPath/$defaultLightning
defaultLightningOutputLogAbsPath="$defaultLightningLogPath/$defaultLightningOutputFilename"
defaultTargetName="release"
defaultLightningSystemdServiceName="$defaultName"
defaultLightningSystemdServiceNameForDocker="docker-$defaultName"
defaultLightningSystemdServicePath="/etc/systemd/system/$defaultLightningSystemdServiceName.service"
defaultLightningSystemdServicePathForDocker="/etc/systemd/system/$defaultLightningSystemdServiceNameForDocker.service"
defaultLightningBasePath="$HOME/.$defaultName"
defaultLightningConfigFilename="config.toml"
defaultLightningConfigPath="$defaultLightningBasePath/$defaultLightningConfigFilename"
Expand Down Expand Up @@ -124,6 +126,53 @@ warningCount=0
echo "✅ The localhost:4230/health is okay"
fi

if [[ -f "$defaultLightningSystemdServicePath" ]]; then
while read -rp "🤖 This process requires to clear the logs and restart the service. Should it clear the logs and restart the service? (yes/no) " answer; do
if [[ "$answer" == [nN] || "$answer" == [nN][oO] ]]; then
echo "👹 Oops! The healthcheck verification was exited."

exit 1
elif [[ "$answer" == [yY] || "$answer" == [yY][eE][sS] ]]; then
sudo rm "$defaultLightningOutputLogAbsPath"
sudo rm "$defaultLightningDiagnosticLogAbsPath"

if [[ -f "$defaultLightningSystemdServicePathForDocker" ]]; then
sudo systemctl restart "$defaultLightningSystemdServiceNameForDocker"
else
sudo systemctl restart "$defaultName"
fi

serverOutputWaitAttempts=0
while [[ -f "$defaultLightningOutputLogAbsPath" && ! -s "$defaultLightningOutputLogAbsPath" ]]; do
echo "🤖 Please wait for the service output logs..."
sleep 5

if [[ "$serverOutputWaitAttempts" -gt 10 ]]; then
break
fi

((serverOutputWaitAttempts++))
done

echo

if ! curl -qsS localhost:4230/health 2>/dev/null | grep -q 'OK'; then
if tail -n 5 "$defaultLightningOutputLogAbsPath" | grep -iq "Node is not staked"; then
echo "⚠️ WARNING: The node is not staked. Have you read the instructions to get onboarded? Find it here https://docs.fleek.network/docs/node/testnet-onboarding"
echo

((warningCount++))
((healthIssueCount++))
fi

break;
fi
fi

printf "💩 Uh-oh! We expect a yes or no answer. Try again...\n"
done
fi

echo
echo
echo "==== Summary ===="
Expand Down

0 comments on commit b21fec3

Please sign in to comment.