fintual-backend-devops-go / bin / optimized
optimized
Raw
#!/usr/bin/env bash
set -euo pipefail
show_help() {
  cat <<'HELP'
Usage: bin/optimized

Serve the optimized Django reference control with Gunicorn.
Requires bin/build and bin/reference setup to have completed.
Needs Python 3.14, uv-installed reference dependencies, and PostgreSQL.

Environment:
  PGDATABASE    Default: assignment_harness_django.
  PGHOST, PGPORT, PGUSER, PGPASSWORD    PostgreSQL connection settings.
  LISTEN_ADDR   Default: 127.0.0.1:18000.
  TMPDIR        Default: ~/codex-tmp.

Do not run the reference server on the same port. Stop with Ctrl+C.
Writes the server PID under .artifacts/.

Example:
  bin/optimized

Options:
  -h, --help    Show this help without performing work.
HELP
}
case "${1:-}" in
  -h|--help|help) show_help; exit 0 ;;
  "") ;;
  *) printf 'Unexpected argument; use bin/optimized --help\n' >&2; exit 2 ;;
esac
project_root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
cd "$project_root"
export PGDATABASE="${PGDATABASE:-assignment_harness_django}"
export DJANGO_SETTINGS_MODULE=experiments.optimized.settings
export TMPDIR="${TMPDIR:-$HOME/codex-tmp}"
mkdir -p "$TMPDIR" .artifacts
exec .venv/bin/gunicorn core.wsgi:application --bind "${LISTEN_ADDR:-127.0.0.1:18000}" \
  --workers 2 --threads 4 --timeout 180 --worker-tmp-dir "$TMPDIR" \
  --pid .artifacts/optimized.pid