issue #0001932 : Script pour la gestion de l'indexation après la consolidation

This commit is contained in:
Michael RICOIS 2014-04-18 12:07:04 +00:00
parent 02ac466cc2
commit d9249f0a41
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,40 @@
#!/bin/bash
PATH_BIN=/usr/local/sphinx/bin
PATH_LOG=/dbs/sphinxlog
PATH_SQL=/home/scripts/indexer/sql
MYSQL_HOST=192.168.3.30
MYSQL_USER=sphinx
MYSQL_PASS=indexer
echo "$(date '+%Y-%m-%d %H:%M:%S') === INDEXATION CIBLAGE" >> $PATH_LOG/indexer.log
# Is consolidated ?
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS sdv1 < $PATH_SQL/consolidate-ciblage.sql)
idx='';
for line in "$output"; do
idx="$line";
done
# Suppression fin de ligne
idx=$(echo $idx|sed -e "s/^[idx ]*//g"||sed -e "s/[ ]*$//g")
# Lancement de l'indexation si la consolidation a eu lieu
if [ -n "$idx" ]; then
if [[ "$idx" > 0 ]]; then
# Enregistrement Debut Indexation
mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS sdv1 -e "INSERT INTO sphinx_idx (indexingBegin) VALUES (NOW()) WHERE id=$idx"
# Sphinx rotate
echo "$(date '+%Y-%m-%d %H:%M:%S') - Sphinx - Debut" >> $PATH_LOG/indexer.log
$PATH_BIN/indexer --config /etc/sphinxsearch/sphinx.conf --rotate ciblage >> $PATH_LOG/indexer.log
echo "$(date '+%Y-%m-%d %H:%M:%S') - Sphinx - Fin" >> $PATH_LOG/indexer.log
# Enregistrement Fin Indexation
mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS sdv1 -e "INSERT INTO sphinx_idx (indexingEnd) VALUES (NOW()) WHERE id=$idx"
fi
fi
echo "$(date '+%Y-%m-%d %H:%M:%S') === FIN INDEXATION CIBLAGE" >> $PATH_LOG/indexer.log

View File

@ -0,0 +1,6 @@
SELECT id FROM sphinx_idx
WHERE createEnd BETWEEN (NOW() - INTERVAL 1 HOUR) AND NOW()
AND nom = 'jo.etablissements_act'
AND indexingBegin IS NULL
AND indexingEnd IS NULL
ORDER BY createEnd DESC LIMIT 1;