Changeset View
Changeset View
Standalone View
Standalone View
docker/services/swh-search/entrypoint.sh
#!/bin/bash | #!/bin/bash | ||||
set -e | set -e | ||||
source /srv/softwareheritage/utils/pyutils.sh | source /srv/softwareheritage/utils/pyutils.sh | ||||
setup_pip | setup_pip | ||||
case "$1" in | case "$1" in | ||||
"shell") | "shell") | ||||
exec bash -i | exec bash -i | ||||
;; | ;; | ||||
*) | *) | ||||
echo Starting the swh-search API server | echo Starting the swh-search API server | ||||
if grep -q elasticsearch $SWH_CONFIG_FILENAME; | |||||
then | |||||
wait-for-it elasticsearch:9200 -s --timeout=0 | wait-for-it elasticsearch:9200 -s --timeout=0 | ||||
echo "Waiting for ElasticSearch cluster to be up" | echo "Waiting for ElasticSearch cluster to be up" | ||||
cat << EOF | python3 | cat << EOF | python3 | ||||
import elasticsearch | import elasticsearch | ||||
es = elasticsearch.Elasticsearch(['elasticsearch:9200']) | es = elasticsearch.Elasticsearch(['elasticsearch:9200']) | ||||
es.cluster.health(wait_for_status='yellow') | es.cluster.health(wait_for_status='yellow') | ||||
EOF | EOF | ||||
echo "ElasticSearch cluster is up" | echo "ElasticSearch cluster is up" | ||||
fi | |||||
swh search -C $SWH_CONFIG_FILENAME initialize | swh search -C $SWH_CONFIG_FILENAME initialize | ||||
exec gunicorn --bind 0.0.0.0:5010 \ | exec gunicorn --bind 0.0.0.0:5010 \ | ||||
--reload \ | --reload \ | ||||
--threads 4 \ | --threads 4 \ | ||||
--workers 2 \ | --workers 2 \ | ||||
--log-level DEBUG \ | --log-level DEBUG \ | ||||
--timeout 3600 \ | --timeout 3600 \ | ||||
--config 'python:swh.core.api.gunicorn_config' \ | --config 'python:swh.core.api.gunicorn_config' \ | ||||
'swh.search.api.server:make_app_from_configfile()' | 'swh.search.api.server:make_app_from_configfile()' | ||||
;; | ;; | ||||
esac | esac |