Skip to content

Commit

Permalink
Fix autoupdate schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
hsoerensen committed Apr 15, 2024
1 parent c350e86 commit ee2dfa6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions bin/get-node-status
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ get_account_info() {
get_participation_expiration_eta() {
local active_key_last_valid_round=$1
local last_committed_block=$2

if ! [[ $1 =~ ^[0-9]+$ ]] || ! [[ $2 =~ ^[0-9]+$ ]]; then
echo "Both arguments must be integers. Exiting."
exit 1
fi

local current_key_blocks_remaining=$((active_key_last_valid_round - last_committed_block))
local remaining_seconds
local current_timestamp
Expand All @@ -57,6 +63,12 @@ display_participation_key_information() {
last_committed_block=$(get_last_committed_block)

active_key_last_valid_round=$(docker exec -it "${container_id}" bash -c 'goal account listpartkeys' | awk '$1=="yes" {print $6}' | tr -cd '[:digit:]')

if [[ -z "${active_key_last_valid_round}" ]]; then
echo "Participation status: No active participation key found."
return 1
fi

existing_expiration_date=$(get_participation_expiration_eta "${active_key_last_valid_round}" "${last_committed_block}")

echo "Participation status: $(docker exec -it "${container_id}" bash -c 'goal account dump -a '"${account_address}"' | jq -r '\''if (.onl == 1) then "online" else "offline" end'\''')"
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ add_update_jitter() {
# Generate a random number between 0 and 2, and add +1 to shift the range to 1-3
random_hour=$(( RANDOM % 3 + 1 ))

new_cron_schedule="swarm.cronjob.schedule=${random_minute} */${random_hour} * * *"
new_cron_schedule="${random_minute} */${random_hour} * * *"
sed -i -E "s|(swarm.cronjob.schedule=).*|\1${new_cron_schedule}|" "${schedule_filename}"
}

Expand Down

0 comments on commit ee2dfa6

Please sign in to comment.