2 years ago
Hey Brody,
Before you suggested this command.
/bin/sh -c "echo 'Waiting for database...'; while ! nc -z ${PGHOST_PRIVATE} ${PGPORT_PRIVATE}; do sleep 0.5; done; echo 'Database is now available'; exec /sbin/tini -- yarn start"Now, we made an update to the engine image. How can I add or monitor if the Redis is up and running? Thanks!
8 Replies
2 years ago
What I did is I added the environment variable for the redis and it works!
2 years ago
You have used the same command again, but just with the private host and port of the redis service, correct?
2 years ago
Yeah I used it and just add the redis environment there just like this.
/bin/sh -c "echo 'Waiting for database...'; while ! nc -z ${PGHOST_PRIVATE} ${PGPORT_PRIVATE} ${REDIS_PRIVATE_URL); do sleep 0.5; done; echo 'Database is now available'; exec /sbin/tini -- yarn start"2 years ago
This is the exact command I use.
/bin/sh -c "echo 'Waiting for database and redis...'; while ! nc -z ${PGHOST_PRIVATE} ${PGPORT_PRIVATE} ${REDIS_PRIVATE_URL}; do sleep 0.5; done; echo 'Database and redis is now available'; exec /sbin/tini -- yarn start"Given that, the service can only accept one command.
2 years ago
You would need to use nc twice separately in the while loop.
But it's likely a safe enough bet to assume redis will be available before postgres so as long as you wait on postgres redis is probably going to be up as well, so please remove the invalid syntax with the private url variable.
2 years ago
Hey brody, done removing the part for redis and yes it is fast enough before the postgres becomes available so it should be fine.