exit 0
fi
else
- if [ "$(docker ps | grep " ${STACK_NAME}_" | grep -i healthy | wc -l)" -ge "$NUM_SERVICES_WITH_HEALTH" ]; then
+ if [ "$(sg docker -c "docker ps" | grep " ${STACK_NAME}_" | grep -i healthy | wc -l)" -ge "$NUM_SERVICES_WITH_HEALTH" ]; then
# all dockers are healthy now.
# final sleep is needed until more health checks are added to validate system is ready to handle requests
sleep $WAIT_FINAL
done
else
echo "Not all Docker services are healthy"
- docker ps | grep " ${STACK_NAME}_"
+ sg docker -c "docker ps" | grep " ${STACK_NAME}_"
for S_WITH_HEALTH in $SERVICES_WITH_HEALTH ; do
- docker ps | grep " ${STACK_NAME}_" | grep -i healthy | grep -q "_${S_WITH_HEALTH}." && continue
+ sg docker -c "docker ps" | grep " ${STACK_NAME}_" | grep -i healthy | grep -q "_${S_WITH_HEALTH}." && continue
echo
echo BEGIN LOGS of container ${S_WITH_HEALTH} not healthy
- docker service logs ${STACK_NAME}_${S_WITH_HEALTH} 2>&1 | tail -n 100
+ sg docker -c "docker service logs ${STACK_NAME}_${S_WITH_HEALTH} 2>&1" | tail -n 100
echo END LOGS of container ${S_WITH_HEALTH} not healthy
echo
done