shlink/docker/docker-entrypoint.sh

46 lines
1.6 KiB
Bash
Raw Normal View History

2019-08-16 19:38:26 +03:00
#!/usr/bin/env sh
set -e
# If SHELL_VERBOSITY was not explicitly provided, run commands in quite mode (-q)
[ $SHELL_VERBOSITY ] && flags="" || flags="-q"
2019-08-16 19:38:26 +03:00
cd /etc/shlink
echo "Creating fresh database if needed..."
php bin/cli db:create -n ${flags}
2019-08-16 19:38:26 +03:00
echo "Updating database..."
php bin/cli db:migrate -n ${flags}
2019-08-16 19:38:26 +03:00
echo "Generating proxies..."
php vendor/doctrine/orm/bin/doctrine.php orm:generate-proxies -n ${flags}
2019-08-16 19:38:26 +03:00
echo "Clearing entities cache..."
php vendor/doctrine/orm/bin/doctrine.php orm:clear-cache:metadata -n ${flags}
# Try to download GeoLite2 db file only if the license key env var was defined
if [ ! -z "${GEOLITE_LICENSE_KEY}" ]; then
echo "Downloading GeoLite2 db file..."
php bin/cli visit:download-db -n ${flags}
fi
# Periodically run visit:locate every hour, if ENABLE_PERIODIC_VISIT_LOCATE=true was provided
if [ $ENABLE_PERIODIC_VISIT_LOCATE ]; then
echo "Configuring periodic visit location..."
2021-05-30 18:41:00 +03:00
echo "0 * * * * php /etc/shlink/bin/cli visit:locate -q" > /etc/crontabs/root
/usr/sbin/crond &
fi
# RoadRunner config needs these to have been set, so falling back to default values if not set yet
export PORT="${PORT:-"8765"}"
export WEB_WORKER_NUM="${WEB_WORKER_NUM:-"16"}"
export TASK_WORKER_NUM="${TASK_WORKER_NUM:-"16"}"
if [ "$SHLINK_RUNTIME" == 'openswoole' ]; then
# When restarting the container, openswoole might think it is already in execution
# This forces the app to be started every second until the exit code is 0
until php vendor/bin/laminas mezzio:swoole:start; do sleep 1 ; done
elif [ "$SHLINK_RUNTIME" == 'rr' ]; then
./bin/rr serve -c config/roadrunner/.rr.yml
fi