29 lines
1.2 KiB
Bash
29 lines
1.2 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
# Bambuddy launcher.
|
||
|
|
#
|
||
|
|
# Starts the FastAPI backend via uvicorn, mirroring the upstream Docker CMD
|
||
|
|
# (`uvicorn backend.app.main:app --loop asyncio`). PYTHONPATH points at the
|
||
|
|
# app root (@out@/share/bambuddy) which contains the `backend` package and
|
||
|
|
# the prebuilt `static/` frontend — the layout backend.app.core.config expects.
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
# State locations. The NixOS module always sets these explicitly; the
|
||
|
|
# defaults keep a bare `bambuddy` invocation out of the read-only store.
|
||
|
|
export DATA_DIR="${DATA_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bambuddy}"
|
||
|
|
export LOG_DIR="${LOG_DIR:-$DATA_DIR/logs}"
|
||
|
|
export HOME="${HOME:-$DATA_DIR}"
|
||
|
|
export MPLCONFIGDIR="${MPLCONFIGDIR:-$DATA_DIR/.cache/matplotlib}"
|
||
|
|
|
||
|
|
mkdir -p "$DATA_DIR" "$LOG_DIR" "$MPLCONFIGDIR"
|
||
|
|
|
||
|
|
export PYTHONPATH="@out@/share/bambuddy${PYTHONPATH:+:$PYTHONPATH}"
|
||
|
|
|
||
|
|
# `--loop asyncio` matches the upstream Dockerfile: uvloop has a TLS bug that
|
||
|
|
# can truncate VP FTP uploads. Override with UVICORN_LOOP=uvloop if desired.
|
||
|
|
exec "@pythonEnv@/bin/uvicorn" backend.app.main:app \
|
||
|
|
--host "${HOST:-0.0.0.0}" \
|
||
|
|
--port "${PORT:-8000}" \
|
||
|
|
--loop "${UVICORN_LOOP:-asyncio}" \
|
||
|
|
--timeout-graceful-shutdown "${UVICORN_TIMEOUT_GRACEFUL_SHUTDOWN:-5}" \
|
||
|
|
"$@"
|