Files
geoip_block_generator/start.sh
Mateusz Gruszczyński c0afc1554d first commit
2026-02-17 09:04:09 +01:00

37 lines
1009 B
Bash
Executable File

#!/bin/bash
set -e
if [ -f /opt/geoip_block_generator/.env ]; then
echo "Loading environment from .env..."
while IFS='=' read -r key value || [ -n "$key" ]; do
[[ "$key" =~ ^[[:space:]]*# ]] && continue
[[ -z "$key" ]] && continue
key=$(echo "$key" | xargs)
value=$(echo "$value" | xargs)
if [[ "$value" =~ ^\"(.*)\"$ ]]; then
value="${BASH_REMATCH[1]}"
elif [[ "$value" =~ ^\'(.*)\'$ ]]; then
value="${BASH_REMATCH[1]}"
fi
export "$key=$value"
done < /opt/geoip_block_generator/.env
fi
# Defaults
FLASK_HOST=${FLASK_HOST:-127.0.0.1}
FLASK_PORT=${FLASK_PORT:-5000}
# Start gunicorn
exec /opt/geoip_block_generator/venv/bin/gunicorn \
--bind "${FLASK_HOST}:${FLASK_PORT}" \
--workers 1 \
--threads 8 \
--worker-class sync \
--timeout 900 \
--access-logfile /var/log/geoip-ban/access.log \
--error-logfile /var/log/geoip-ban/error.log \
app:app