You've already forked docker-ara
53 lines
2.0 KiB
Bash
53 lines
2.0 KiB
Bash
|
|
#!/bin/bash
|
|||
|
|
set -e
|
|||
|
|
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
# Timezone — controls when crond fires, not just ARA display times.
|
|||
|
|
# Set TZ at runtime, e.g.: -e TZ=Pacific/Auckland
|
|||
|
|
# Defaults to UTC if not set.
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
TZ="${TZ:-UTC}"
|
|||
|
|
ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime
|
|||
|
|
echo "${TZ}" > /etc/timezone
|
|||
|
|
export TZ
|
|||
|
|
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
# Configurable retention period (days) – override via environment variable
|
|||
|
|
# Default: 30 days
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
PRUNE_DAYS="${ARA_PRUNE_DAYS:-30}"
|
|||
|
|
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
# Cron schedule for pruning – override via environment variable
|
|||
|
|
# Default: daily at 02:00
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
PRUNE_CRON="${ARA_PRUNE_CRON:-0 2 * * *}"
|
|||
|
|
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
# Write the cron job
|
|||
|
|
# Uses `ara playbook prune` with the offline client so it talks directly
|
|||
|
|
# to the same database without needing a running HTTP server.
|
|||
|
|
# ARA_BASE_DIR is inherited from the container environment.
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
echo "${PRUNE_CRON} /usr/local/bin/ara playbook prune \
|
|||
|
|
--client offline \
|
|||
|
|
--days ${PRUNE_DAYS} \
|
|||
|
|
--limit 9000 \
|
|||
|
|
--confirm >> /proc/1/fd/1 2>&1" \
|
|||
|
|
| crontab -
|
|||
|
|
|
|||
|
|
# Start the cron daemon in the background
|
|||
|
|
crond -n &
|
|||
|
|
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
# Run DB migrations then start gunicorn
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
/usr/local/bin/ara-manage migrate
|
|||
|
|
|
|||
|
|
exec python3 -m gunicorn \
|
|||
|
|
--workers="${ARA_GUNICORN_WORKERS:-4}" \
|
|||
|
|
--access-logfile - \
|
|||
|
|
--bind "[::]:${ARA_PORT:-8000}" \
|
|||
|
|
--access-logformat '%({x-forwarded-for}i)s %l %u %t "%r" %s %b "%f" "%a"' \
|
|||
|
|
ara.server.wsgi
|