Last active
October 22, 2021 17:33
-
-
Save irving-caamal/c47ddb31aaaf06f06e54d49d30cd5f89 to your computer and use it in GitHub Desktop.
Check and wait for a service in any linux distro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need Netcat to run this successfully.