Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-26 08:40:22

0001 #!/bin/bash
0002 # Cron wrapper for the prod-ops cleaner-killer.
0003 #
0004 # cron does not source the deploy's EnvironmentFile, but the liveness ping needs
0005 # the ACTIVEMQ_* settings to reach the broker. Load production.env, then exec
0006 # the standalone reaper. All args are passed through (e.g. --prune-days 30).
0007 #
0008 # Install (Torre, root) — see docs/EPICPROD_OPS.md:
0009 #   */2 * * * *  /opt/swf-monitor/current/scripts/prodops-cleaner-killer.sh
0010 #   30 3 * * *   /opt/swf-monitor/current/scripts/prodops-cleaner-killer.sh --no-liveness --prune-days 30
0011 set -eo pipefail
0012 
0013 ENV_FILE="${EPICPROD_ENV_FILE:-/opt/swf-monitor/config/env/production.env}"
0014 PYTHON="${EPICPROD_PYTHON:-/opt/swf-monitor/current/.venv/bin/python}"
0015 SCRIPT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/prodops-cleaner-killer.py"
0016 
0017 # production.env is a Django/decouple env file, NOT a bash script: values may
0018 # contain $ & ( ) etc. unquoted (e.g. SECRET_KEY), so `source` chokes on them.
0019 # Parse it the way systemd's EnvironmentFile does — literal KEY=VALUE, no shell
0020 # evaluation — and export each for the python reaper.
0021 if [ -f "$ENV_FILE" ]; then
0022     while IFS='=' read -r key val || [[ -n "$key" ]]; do
0023         [[ "$key" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]] || continue   # skip comments/blanks
0024         val="${val%\"}"; val="${val#\"}"                       # strip optional "quotes"
0025         export "$key=$val"
0026     done < "$ENV_FILE"
0027 fi
0028 
0029 exec "$PYTHON" "$SCRIPT" "$@"