Changeset View
Changeset View
Standalone View
Standalone View
docker/services/swh-web/entrypoint.sh
#!/bin/bash | #!/bin/bash | ||||
set -e | set -e | ||||
source /srv/softwareheritage/utils/pgsql.sh | source /srv/softwareheritage/utils/pgsql.sh | ||||
setup_pgsql | setup_pgsql | ||||
# when overriding swh-web sources only | # when overriding swh-web sources only | ||||
if [[ -d /src/swh-web ]] ; then | if [[ -d /src/swh-web ]] ; then | ||||
echo "Install and compile swh-web static assets" | echo "Install and compile swh-web static assets" | ||||
pushd /src/swh-web | pushd /src/swh-web | ||||
yarn install --frozen-lockfile | yarn install --frozen-lockfile | ||||
yarn build-dev | # execute webpack-dev-server in background | ||||
yarn start-dev& | |||||
popd | popd | ||||
# force the use of swh-web develomment settings | |||||
export DJANGO_SETTINGS_MODULE=swh.web.settings.development | |||||
fi | fi | ||||
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 | ||||
Show All 21 Lines | *) | ||||
(date && django-admin refresh_savecodenow_statuses \ | (date && django-admin refresh_savecodenow_statuses \ | ||||
--settings=${DJANGO_SETTINGS_MODULE} 2>&1) >> /tmp/refresh-statuses.log | --settings=${DJANGO_SETTINGS_MODULE} 2>&1) >> /tmp/refresh-statuses.log | ||||
sleep 15 | sleep 15 | ||||
done | done | ||||
) & | ) & | ||||
disown | disown | ||||
echo "starting the swh-web server" | echo "starting the swh-web server" | ||||
if [[ -d /src/swh-web ]] ; then | |||||
# run django development server when overriding swh-web sources | |||||
exec django-admin runserver --nostatic --settings=${DJANGO_SETTINGS_MODULE} 0.0.0.0:5004 | |||||
else | |||||
# run gunicorn workers as in production otherwise | |||||
exec gunicorn --bind 0.0.0.0:5004 \ | exec gunicorn --bind 0.0.0.0:5004 \ | ||||
--threads 2 \ | --threads 2 \ | ||||
--workers 2 \ | --workers 2 \ | ||||
--timeout 3600 \ | --timeout 3600 \ | ||||
--access-logfile '-' \ | --access-logfile '-' \ | ||||
--config 'python:swh.web.gunicorn_config' \ | --config 'python:swh.web.gunicorn_config' \ | ||||
'django.core.wsgi:get_wsgi_application()' | 'django.core.wsgi:get_wsgi_application()' | ||||
fi | |||||
esac | esac |