Skip to content

Commit

Permalink
feat: adapt entrypoint.sh to retry the migration with a sleep of 60s (#…
Browse files Browse the repository at this point in the history
…779)

* feat: adapt entrypoint.sh to retry the migration with a sleep of 60s

* feat: use 10 retries and 30s

* feat: use seq and variables
  • Loading branch information
juanmahidalgo authored Oct 24, 2024
1 parent 700c238 commit ce9adc5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,17 @@ if [[ -z "${CONNECTION_STRING}" ]]; then
export CONNECTION_STRING=postgres://${PG_COMPONENT_PSQL_USER}:${PG_COMPONENT_PSQL_PASSWORD}@${PG_COMPONENT_PSQL_HOST}:${PG_COMPONENT_PSQL_PORT}/${PG_COMPONENT_PSQL_DATABASE}
fi

npm run migrate:docker up || exit 1
MAX_RETRIES=10
RETRY_DELAY=30

for i in $(seq 1 $MAX_RETRIES); do
npm run migrate:docker up && break || echo "Migration failed, retrying... ($i/$MAX_RETRIES)"
sleep $RETRY_DELAY
done

if [ $i -eq $MAX_RETRIES ]; then
echo "Migration failed after $MAX_RETRIES attempts, exiting..."
exit 1
fi

node --inspect="0.0.0.0:9229" ./dist/src/server.js || exit 1

0 comments on commit ce9adc5

Please sign in to comment.