Last active
February 27, 2016 14:36
-
-
Save acdha/e140179134a780aecebf to your computer and use it in GitHub Desktop.
Crude but effective cron watchdog for Apache Solr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
exec >/dev/null | |
sleep $((120 + ($RANDOM % 1800))) | |
curl -s http://localhost:8986/solr/{ar,en,es,fr,pt,ru,zh}/update -H 'Content-Type: text/xml' --data-binary '<commit waitSearcher="true"/>' | |
curl -s http://localhost:8986/solr/{ar,en,es,fr,pt,ru,zh}/update -H "Content-Type: text/xml" --data-binary '<optimize/>' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
# Test whether Solr is up several times to avoid race conditions when Solr is | |
# starting up or very busy (i.e. rebuilding & optimizing the index) | |
for i in `seq 1 15`; do | |
curl -o /dev/null --silent --fail --show-error 'http://127.0.0.1:8986/solr/en/admin/ping' && exit 0 | |
sleep 1 | |
done | |
logger -s -t wdl-solr-watchdog "Solr is unresponsive. Attempting to restart..." | |
# Ensure that the permissions have not been clobbered by another task and that the directory | |
# has not been removed: | |
install -d -m 0755 /opt/wdl/solr/work | |
# We rely on Upstart to restart Solr after it exists. | |
pkill -n -f wdl/solr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment