Skip to content

Commit

Permalink
fix: hubble autoupgrade should ensure dependencies and clean unused d…
Browse files Browse the repository at this point in the history
…ocker data (#1542)

* fix: hubble autoupgrade should ensure dependencies and clean unused docker data

* Add env var to bypass self upgrade

* Don't restart more than 5 times on failure

* Fix docker command
  • Loading branch information
sanjayprabhu authored Oct 20, 2023
1 parent f7effc2 commit 559afd0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-guests-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farcaster/hubble": patch
---

fix: hubble autoupgrade should ensure dependencies and clean unused docker data
2 changes: 1 addition & 1 deletion apps/hubble/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
hubble:
image: farcasterxyz/hubble:latest
pull_policy: always
restart: unless-stopped
restart: on-failure:5
command: [
"node", "--no-warnings", "build/cli.js", "start",
"--ip", "0.0.0.0",
Expand Down
21 changes: 20 additions & 1 deletion scripts/hubble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ fetch_file_from_repo() {
}

# Upgrade the script
self_upgrade() {
self_upgrade() {
# To allow easier testing
if key_exists "SKIP_SELF_UPGRADE"; then
echo "Skipping self upgrade"
return 1
fi

local tmp_file
tmp_file=$(mktemp)
fetch_file_from_repo "$SCRIPT_FILE_PATH" "$tmp_file"
Expand Down Expand Up @@ -420,6 +426,12 @@ start_hubble() {
$COMPOSE_CMD up -d hubble
}

cleanup() {
# Prune unused docker cruft. Make sure to call this only when hub is already running
echo "Pruning unused docker images and volumes"
docker system prune --volumes -f
}

set_compose_command() {
# Detect whether "docker-compose" or "docker compose" is available
if command -v docker-compose &> /dev/null; then
Expand Down Expand Up @@ -568,6 +580,10 @@ if [ "$1" == "autoupgrade" ]; then

echo "$(date) Attempting hubble autoupgrade..."

# Since cronjob is running under root, make sure the dependencies are installed
install_jq
install_docker "$@"

set_platform_commands
set_compose_command

Expand All @@ -576,6 +592,9 @@ if [ "$1" == "autoupgrade" ]; then
fetch_latest_docker_compose_and_dashboard
ensure_grafana
start_hubble
sleep 5
cleanup

echo "$(date) Completed hubble autoupgrade"

exit 0
Expand Down

0 comments on commit 559afd0

Please sign in to comment.