Changeset View
Changeset View
Standalone View
Standalone View
services/swh-storage/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 | ||||
if [ "$STORAGE_BACKEND" = "postgresql" ]; then | |||||
source /srv/softwareheritage/utils/pgsql.sh | source /srv/softwareheritage/utils/pgsql.sh | ||||
setup_pgsql | setup_pgsql | ||||
elif [ "$STORAGE_BACKEND" = "cassandra" ]; then | |||||
echo Waiting for Cassandra to start | |||||
wait-for-it ${CASSANDRA_SEED}:9042 -s --timeout=0 | |||||
echo Creating keyspace | |||||
cat << EOF | python3 | |||||
from swh.storage.cassandra import create_keyspace | |||||
create_keyspace(['cassandra-seed'], 'swh') | |||||
EOF | |||||
fi | |||||
case "$1" in | case "$1" in | ||||
"shell") | "shell") | ||||
exec bash -i | exec bash -i | ||||
;; | ;; | ||||
*) | *) | ||||
if [ "$STORAGE_BACKEND" = "postgresql" ]; then | |||||
wait_pgsql | wait_pgsql | ||||
echo Setup the database | echo Setup the database | ||||
PGPASSWORD=${POSTGRES_PASSWORD} swh-db-init storage \ | PGPASSWORD=${POSTGRES_PASSWORD} swh-db-init storage \ | ||||
--db-name ${POSTGRES_DB} | --db-name ${POSTGRES_DB} | ||||
fi | |||||
echo Starting the swh-storage API server | echo Starting the swh-storage API server | ||||
exec gunicorn --bind 0.0.0.0:5002 \ | exec gunicorn --bind 0.0.0.0:5002 \ | ||||
--reload \ | --reload \ | ||||
--threads 4 \ | --threads 4 \ | ||||
--workers 2 \ | --workers 2 \ | ||||
--log-level DEBUG \ | --log-level DEBUG \ | ||||
--timeout 3600 \ | --timeout 3600 \ | ||||
swh.storage.api.wsgi | swh.storage.api.wsgi | ||||
;; | ;; | ||||
esac | esac |