Skip to content

Commit

Permalink
up --wait everything
Browse files Browse the repository at this point in the history
  • Loading branch information
BYK committed Dec 23, 2024
1 parent 97fcda0 commit db60eb5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 29 deletions.
8 changes: 1 addition & 7 deletions install/set-up-and-migrate-database.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
echo "${_group}Setting up / migrating database ..."

# Fixes https://github.com/getsentry/self-hosted/issues/2758, where a migration fails due to indexing issue
$dc up -d postgres
# Wait for postgres
RETRIES=5
until $dc exec postgres psql -U postgres -c "select 1" >/dev/null 2>&1 || [ $RETRIES -eq 0 ]; do
echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..."
sleep 1
done
$dc up --wait postgres

os=$($dc exec postgres cat /etc/os-release | grep 'ID=debian')
if [[ -z $os ]]; then
Expand Down
20 changes: 3 additions & 17 deletions install/upgrade-clickhouse.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
echo "${_group}Upgrading Clickhouse ..."

function wait_for_clickhouse() {
# Wait for clickhouse
RETRIES=30
until $dc ps clickhouse | grep 'healthy' || [ $RETRIES -eq 0 ]; do
echo "Waiting for clickhouse server, $((RETRIES--)) remaining attempts..."
sleep 1
done
}

# First check to see if user is upgrading by checking for existing clickhouse volume
if [[ -n "$(docker volume ls -q --filter name=sentry-clickhouse)" ]]; then
# Start clickhouse if it is not already running
$dc up -d clickhouse

# Wait for clickhouse
wait_for_clickhouse
$dc up --wait clickhouse

# In order to get to 23.8, we need to first upgrade go from 21.8 -> 22.8 -> 23.3 -> 23.8
version=$($dc exec clickhouse clickhouse-client -q 'SELECT version()')
if [[ "$version" == "21.8.13.1.altinitystable" || "$version" == "21.8.12.29.altinitydev.arm" ]]; then
$dc down clickhouse
$dcb --build-arg BASE_IMAGE=altinity/clickhouse-server:22.8.15.25.altinitystable clickhouse
$dc up -d clickhouse
wait_for_clickhouse
$dc up --wait clickhouse
$dc down clickhouse
$dcb --build-arg BASE_IMAGE=altinity/clickhouse-server:23.3.19.33.altinitystable clickhouse
$dc up -d clickhouse
wait_for_clickhouse
$dc up --wait clickhouse
else
echo "Detected clickhouse version $version. Skipping upgrades!"
fi
Expand Down
2 changes: 1 addition & 1 deletion install/upgrade-postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if [[ -n "$(docker volume ls -q --filter name=sentry-postgres)" && "$(docker run
docker volume rm sentry-postgres-new
echo "Re-indexing due to glibc change, this may take a while..."
echo "Starting up new PostgreSQL version"
$dc up -d postgres
$dc up --wait postgres

# Wait for postgres
RETRIES=5
Expand Down
8 changes: 4 additions & 4 deletions install/wrap-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ if [[ "$MINIMIZE_DOWNTIME" ]]; then
echo "${_group}Waiting for Sentry to start ..."

# Start the whole setup, except nginx and relay.
$dc up -d --remove-orphans $($dc config --services | grep -v -E '^(nginx|relay)$')
$dc up --wait --remove-orphans $($dc config --services | grep -v -E '^(nginx|relay)$')
$dc restart relay
$dc exec -T nginx nginx -s reload

docker run --rm --network="${COMPOSE_PROJECT_NAME}_default" alpine ash \
-c 'while [[ "$(wget -T 1 -q -O- http://web:9000/_health/)" != "ok" ]]; do sleep 0.5; done'

# Make sure everything is up. This should only touch relay and nginx
$dc up -d
$dc up --wait

echo "${_endgroup}"
else
Expand All @@ -20,9 +20,9 @@ else
echo "You're all done! Run the following command to get Sentry running:"
echo ""
if [[ "${_ENV}" =~ ".env.custom" ]]; then
echo " $dc_base --env-file ${_ENV} up -d"
echo " $dc_base --env-file ${_ENV} up --wait"
else
echo " $dc_base up -d"
echo " $dc_base up --wait"
fi
echo ""
echo "-----------------------------------------------------------------"
Expand Down

0 comments on commit db60eb5

Please sign in to comment.