Browse Source

verifica quatro vezes se solr esta online (#2732)

pull/2811/head
Ricardo Lima Canela 6 years ago
committed by Cesar Carvalho
parent
commit
a1b4f3d0a7
  1. 1
      Dockerfile
  2. 13
      check_solr.sh
  3. 14
      start.sh

1
Dockerfile

@ -39,6 +39,7 @@ RUN rm -rf /var/interlegis/sapl/sapl/.env && \
rm -rf /var/interlegis/sapl/sapl.db rm -rf /var/interlegis/sapl/sapl.db
RUN chmod +x /var/interlegis/sapl/start.sh && \ RUN chmod +x /var/interlegis/sapl/start.sh && \
chmod +x /var/interlegis/sapl/check_solr.sh && \
ln -sf /dev/stdout /var/log/nginx/access.log && \ ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log && \ ln -sf /dev/stderr /var/log/nginx/error.log && \
mkdir /var/log/sapl/ && touch /var/interlegis/sapl/sapl.log && \ mkdir /var/log/sapl/ && touch /var/interlegis/sapl/sapl.log && \

13
check_solr.sh

@ -4,15 +4,22 @@
SOLR_URL=$1 SOLR_URL=$1
RETRY_COUNT=1
RETRY_LIMIT=4
echo "Waiting for solr connection at $SOLR_URL ..." echo "Waiting for solr connection at $SOLR_URL ..."
while true; do while [[ $RETRY_COUNT < $RETRY_LIMIT ]]; do
echo "Attempt to connect to solr: $RETRY_COUNT of $RETRY_LIMIT"
let RETRY_COUNT=RETRY_COUNT+1;
echo "$SOLR_URL/solr/admin/collections?action=LIST" echo "$SOLR_URL/solr/admin/collections?action=LIST"
RESULT=$(curl -s -o /dev/null -I "$SOLR_URL/solr/admin/collections?action=LIST" -w '%{http_code}') RESULT=$(curl -s -o /dev/null -I "$SOLR_URL/solr/admin/collections?action=LIST" -w '%{http_code}')
echo $RESULT echo $RESULT
if [ "$RESULT" -eq '200' ]; then if [ $RESULT == 200 ]; then
echo "Solr server is up!" echo "Solr server is up!"
break exit 1
else else
sleep 3 sleep 3
fi fi
done done
echo "Solr connection failed."
exit 2

14
start.sh

@ -71,11 +71,19 @@ if [ "${USE_SOLR-False}" == "True" ] || [ "${USE_SOLR-False}" == "true" ]; then
echo "REPLICATION FACTOR: $RF" echo "REPLICATION FACTOR: $RF"
echo "MAX SHARDS PER NODE: $MAX_SHARDS_PER_NODE" echo "MAX SHARDS PER NODE: $MAX_SHARDS_PER_NODE"
echo "=========================================" echo "========================================="
echo "running solr script"
/bin/bash check_solr.sh $SOLR_URL /bin/bash check_solr.sh $SOLR_URL
CHECK_SOLR_RETURN=$?
if [ $CHECK_SOLR_RETURN == 1 ]; then
echo "Connecting to solr..."
python3 solr_api.py -u $SOLR_URL -c $SOLR_COLLECTION -s $NUM_SHARDS -rf $RF -ms $MAX_SHARDS_PER_NODE &
# python3 manage.py rebuild_index --noinput &
else
echo "Solr is offline, not possible to connect."
fi
python3 solr_api.py -u $SOLR_URL -c $SOLR_COLLECTION -s $NUM_SHARDS -rf $RF -ms $MAX_SHARDS_PER_NODE &
# python3 manage.py rebuild_index --noinput &
else else
echo "Suporte a SOLR não inicializado." echo "Suporte a SOLR não inicializado."
fi fi

Loading…
Cancel
Save