Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shams-ali/b5777887d28a6638c4cf72027eec1c72 to your computer and use it in GitHub Desktop.
Save shams-ali/b5777887d28a6638c4cf72027eec1c72 to your computer and use it in GitHub Desktop.
wait for db container to be available before starting server
#!/bin/bash THIS WORKED
bash -c 'while ! </dev/tcp/db/5432; do sleep 1; done; nodal db:bootstrap && nodal s;'
#THIS WORKS ONLY IF NETSTST INSTALLED
while ! nc -w 1 -z db 5432; do sleep 0.1; done
#ANOTHER WAY
until nc -z postgres 5432; do
echo "$(date) - waiting for postgres..."
sleep 1
done
@kaushikacharya
Copy link

kaushikacharya commented Nov 1, 2022

#THIS WORKS ONLY IF NETSTST INSTALLED

I believe you meant netcat.

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