Skip to content

Instantly share code, notes, and snippets.

@irving-caamal
Last active October 22, 2021 17:33
Show Gist options
  • Select an option

  • Save irving-caamal/c47ddb31aaaf06f06e54d49d30cd5f89 to your computer and use it in GitHub Desktop.

Select an option

Save irving-caamal/c47ddb31aaaf06f06e54d49d30cd5f89 to your computer and use it in GitHub Desktop.
Check and wait for a service in any linux distro
#!/bin/sh
# $: means that is an ENV variable
if [ "$DATABASE" = "postgres" ]
then
echo "Waiting for postgres..."
while ! nc -z $POSTGRESQL_ADDON_HOST $POSTGRESQL_ADDON_PORT; do
sleep 0.1
done
echo "PostgreSQL started"
fi
python manage.py flush --no-input
python manage.py makemigrations
python manage.py migrate
exec "$@"
@irving-caamal
Copy link
Copy Markdown
Author

You need Netcat to run this successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment