Changeset View
Changeset View
Standalone View
Standalone View
docker/services/swh-graph/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 | ||||
DATADIR=/srv/softwareheritage/graph | DATADIR=/srv/softwareheritage/graph | ||||
case "$1" in | update_graph() { | ||||
"shell") | |||||
exec bash -i | |||||
;; | |||||
*) | |||||
mkdir -p $DATADIR/ | mkdir -p $DATADIR/ | ||||
rm -rf $DATADIR/* # cleanup results from previous runs | rm -rf $DATADIR/* # cleanup results from previous runs | ||||
mkdir $DATADIR/g/ | mkdir $DATADIR/g/ | ||||
echo "Exporting edges and nodes" | echo "Exporting edges and nodes" | ||||
swh dataset -C $SWH_CONFIG_FILENAME graph export $DATADIR/g --processes=4 | swh dataset -C $SWH_CONFIG_FILENAME graph export $DATADIR/g --processes=4 | ||||
echo "Sorting edges and nodes" | echo "Sorting edges and nodes" | ||||
swh dataset graph sort $DATADIR/g/edges | swh dataset graph sort $DATADIR/g/edges | ||||
echo "Compressing graph" | echo "Compressing graph" | ||||
swh graph compress --graph $DATADIR/g/edges/graph --outdir $DATADIR/compressed | swh graph compress --graph $DATADIR/g/edges/graph --outdir $DATADIR/compressed | ||||
} | |||||
case "$1" in | |||||
"shell") | |||||
exec bash -i | |||||
;; | |||||
"update") | |||||
update_graph | |||||
;; | |||||
*) | |||||
if [[ ! -d $DATADIR/compressed ]] ; then | |||||
# Generate the graph if it wasn't already | |||||
update_graph | |||||
fi | |||||
echo "Starting the swh-graph API server" | echo "Starting the swh-graph API server" | ||||
exec gunicorn --bind 0.0.0.0:5009 \ | exec gunicorn --bind 0.0.0.0:5009 \ | ||||
--worker-class aiohttp.worker.GunicornWebWorker \ | --worker-class aiohttp.worker.GunicornWebWorker \ | ||||
--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.graph.server.app:make_app_from_configfile()' | 'swh.graph.server.app:make_app_from_configfile()' | ||||
;; | ;; | ||||
esac | esac |