Files
Seg_Data_Server_Net/scripts/run_backend.sh
2026-06-30 17:33:15 +08:00

26 lines
586 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
if [[ -f "${ROOT_DIR}/.env" ]]; then
set -a
# shellcheck disable=SC1091
source "${ROOT_DIR}/.env"
set +a
fi
BACKEND_ENV="${SEG_BACKEND_CONDA_ENV:-seg_smp}"
HOST="${SEG_BACKEND_HOST:-0.0.0.0}"
PORT="${SEG_BACKEND_PORT:-8010}"
RELOAD="${SEG_BACKEND_RELOAD:-1}"
cd "${ROOT_DIR}"
args=(uvicorn app.main:app --app-dir backend --host "${HOST}" --port "${PORT}")
case "${RELOAD,,}" in
1|true|yes|on)
args+=(--reload)
;;
esac
exec conda run -n "${BACKEND_ENV}" "${args[@]}"