issue #0001932 : Script pour la gestion de l'indexation après la consolidation
This commit is contained in:
parent
02ac466cc2
commit
d9249f0a41
40
indexer/indexer-ciblage.sh
Normal file
40
indexer/indexer-ciblage.sh
Normal 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
|
||||
|
||||
|
6
indexer/sql/consolidate-ciblage.sql
Normal file
6
indexer/sql/consolidate-ciblage.sql
Normal 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;
|
Loading…
Reference in New Issue
Block a user