Skip to content

Commit

Permalink
improved logging and monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
marczeller committed Aug 18, 2024
1 parent 221ff5b commit ba0610d
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions dolce_vita_collector_with_notifications.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ send_telegram_message() {
curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage" -d chat_id="$TELEGRAM_CHAT_ID" -d text="$message"
}

# Function to log messages
# Function to log messages and send to Telegram
log_message() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE"
send_telegram_message "$1"
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
local message="[$timestamp] $1"
echo "$message" | tee -a "$LOG_FILE"
send_telegram_message "$message"
}

# Check for command line arguments
Expand Down Expand Up @@ -63,10 +65,19 @@ else
fi

# Run make mint for each network without checking for success
for network in "${NETWORKS[@]}"; do
log_message "Running make mint for $network"
TOTAL_NETWORKS=${#NETWORKS[@]}
for ((i=0; i<$TOTAL_NETWORKS; i++)); do
network=${NETWORKS[$i]}
log_message "($((i+1))/$TOTAL_NETWORKS) Starting make mint for $network"
timeout 180 make mint NETWORK=$network
log_message "Completed make mint for $network"
mint_result=$?
if [ $mint_result -eq 0 ]; then
log_message "($((i+1))/$TOTAL_NETWORKS) ✅ Completed make mint for $network successfully"
elif [ $mint_result -eq 124 ]; then
log_message "($((i+1))/$TOTAL_NETWORKS) ⏱️ make mint for $network timed out after 180 seconds"
else
log_message "($((i+1))/$TOTAL_NETWORKS) ❌ make mint for $network failed with exit code $mint_result"
fi
done

log_message "🏁 Dolce Vita Collector script completed"

0 comments on commit ba0610d

Please sign in to comment.